Skip to content
This repository has been archived by the owner on Feb 21, 2020. It is now read-only.

cluster counting routine for statistical physics (biology,...) 2-d site model

License

Notifications You must be signed in to change notification settings

jlapeyre/PDL-StatPhys-Cluster

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OVERVIEW

A module for PDL providing cluster counting for 2-d, site, statistical models. This module is not on the CPAN.

NAME

PDL::StatPhys::Cluster - routines for cluster counting

DESCRIPTION

Cluster counting, and some percolations routines. These routines find the clusters on a 2-d array of integers where a given integer represents and empty site and any other value represents an occupied site. Two occupied sites are in the same cluster if they are nearest neighbors. The algorithm is a weighted union-find with path compression known as the Hoshen-Kopelman algorithm.

See also the connected component function "ccNcompt" in PDL::Image2D.

SYNOPSIS

use PDL;
use PDL::StatPhys::Cluster;
use PDL::NiceSlice;

$c = pdl long , [ 
    [1,1,0,1,1],
    [1,1,0,0,0],
    [1,1,0,1,0],
    [0,0,0,0,0],
    [1,1,1,0,1],
    [1,1,1,0,1]
   ];
      ($max_cluster_size, $num_clusters, $cluster_size_distribution) = clustdist($c);

FUNCTIONS

clustdist()

Example:

($max_cluster_size, $num_clusters, $cluster_size_distribution) = clustdist($lattice);

Usage:

($max_cluster_size, $num_clusters, $cluster_size_distribution) = clustdist($lattice, {OPTIONS} );

Options:

closed_site => n
value of a closed (unoccupied) site. All other values are considered open (occupied).
Default 0.

Find clusters in $lattice and compute the distribution of cluster masses, where the mass is the number of open sites in a cluster. The return values are the size of the largest cluster, the number of clusters, and a 1-d pdl containing the cluster counts. The ith element is the number of clusters of mass i-1. (There are no clusters of mass zero.)

site_perc_sample()

Usage:

site_perc_sample($lattice, $p,  {OPTIONS} );

Options:

open_site => n
value of an open (occupied) site.  closed (unoccupied) sites have value zero.
Default 1. If the lattice is a piddle of bytes, you could set this to 255 for
instance so that occupied sites are represented by white in an image.

Sample a site percolation process with site density $p. This routine is simple and short and uses the builtin perl RNG via PDL. A temporary piddle of doubles with the same dimensions as $lattice is created. The input piddle can have any shape. Each element of $lattice is set to open_site with probability $p and to 0 with probability 1-$p.

Example:

$lattice = byte zeroes(300,300);
site_perc_sample($lattice, .5926);

CONSTANTS

PDL::Cluster::SITE_PERC_2D_PC

The threshold for site percolation on a 2d square lattice. 0.5927462

BUGS

None known.

AUTHOR

This file copyright (C) 2012, John Lapeyre (jlapeyre@cpan.org), All rights reserved. There is no warranty. You are allowed to redistribute this software / documentation under certain conditions. For details, see the file COPYING in the PDL distribution. If this file is separated from the PDL distribution, the copyright notice should be included in the file.

About

cluster counting routine for statistical physics (biology,...) 2-d site model

Resources

License

Stars

Watchers

Forks

Packages

No packages published