| Summary | Package variables | Synopsis | General documentation | Methods |
| Summary | Top |
| Clair::Gen - Generator Class for the CLAIR Library head1 VERSION Version 0.01 |
| Package variables | Top |
| No package variables defined. |
| Included modules | Top |
| Clair::ChisqIndependent |
| Math::Random qw ( random_poisson ) |
| POSIX |
| Statistics::ChisqIndep |
| Synopsis | Top |
| This module works with distributions: to produce random and expected distributions and to compare them. It works with Poisson and Power Law distributions. |
| Description | Top |
| Methods | Top |
| compareChiSquare | Description | Code |
| count | Description | Code |
| distribution | Description | Code |
| genPL | Description | Code |
| genPois | Description | Code |
| new | Description | Code |
| plEstimate | Description | Code |
| poissonEstimate | Description | Code |
| read_from_file | Description | Code |
| compareChiSquare | code | next | Top |
| ($df, $p_value) = compareChiSquare(\@observed, \@expected, $df); Performs a chi square comparison of observed and expected values. Reduces the number of degrees of freedom by the value in $df. Returns the number of degrees of freedom and the p-value. |
| count | code | prev | next | Top |
| count Returns the number of elements in the distribution |
| distribution | code | prev | next | Top |
| distribution Returns the distribution. |
| genPL | code | prev | next | Top |
| genPL($c_hat, $alpha_hat, $n) Generates the expected power law distribution for the given values of c_hat, alpha_hat, and the number of keys |
| genPois | code | prev | next | Top |
| genPois($l, $n) Generates a random poisson distribution for the provided values of n and l. |
| new | code | prev | next | Top |
| $gen = new Clair::Gen(distribution => \@dist); Creates a Gen class with the specified distribution. If no distribution is given, the class is created with an empty distribution. |
| plEstimate | code | prev | next | Top |
| ($c_hat, $alpha_hat) = plEstimate(\@observed) Estimates the values for c_hat and alpha_hat for the observed distribution as a power law distribution. |
| poissonEstimate | code | prev | next | Top |
| poissonEstimate Does nothing currently. A stub is in place for a function that will behave like the power law estimate above, but for a poisson distribution |
| read_from_file | code | prev | next | Top |
| read_from_file($filename); Reads a distribution from a file. Distribution should have lines with the format: value key |
| compareChiSquare | description | prev | next | Top |
sub compareChiSquare
{my $self = shift; my $obs = shift; my @observed = @$obs; my $exp = shift; my @expected = @$exp; my $extra_df = shift; my @chi_array = (\@observed,\@ expected); my $chi = new Clair::ChisqIndependent; $chi->load_data(\@chi_array); $chi->{df} -= $extra_df; $chi->recompute_chisq(); return ($chi->{df}, $chi->{p_value});} |
| count | description | prev | next | Top |
sub count
{ my $self = shift;
my $dist = $self->{distribution};
my @distribution = @$dist;
my $count = @distribution;
return $count;} |
| distribution | description | prev | next | Top |
sub distribution
{ my $self = shift;
my $dist = $self->{distribution};
return @$dist;} |
| genPL | description | prev | next | Top |
sub genPL
{ my $self = shift;
my $c_hat = shift;
my $alpha_hat = shift;
my $n = shift;
my @ret_array;
foreach my $i (1..$n) {
my $j = $c_hat * $i ** $alpha_hat;
# print "$j $i\n";} |
| genPois | description | prev | next | Top |
sub genPois
{my $self = shift; my $l = shift; my $n = shift; my @obs = &random_poisson($n, $l); return @obs;} |
| new | description | prev | next | Top |
sub new
{ my $class = shift;
my %parameters = @_;
my @distribution = ();
if (exists $parameters{distribution}) {
my $d = $parameters{distribution};
@distribution = @$d;
}
my $self = bless {
distribution =>\@ distribution,
}, $class;
return $self;} |
| plEstimate | description | prev | next | Top |
sub plEstimate
{my $self = shift; my $obs = shift; my @observed = @$obs; my %points; # x_total is the sum of all x's} |
| poissonEstimate | description | prev | next | Top |
sub poissonEstimate
{my $self = shift; return 0;} |
| read_from_file | description | prev | next | Top |
sub read_from_file
{ my $self = shift;
my $filename = shift;
open(FILE, "< $filename");
my $largest_key = 0;
my %dist_hash = ();
while (<FILE>) {
next unless m/(.+) (.+)/;
my $value = $1;
my $key = $2;
$dist_hash{$key} = $value;
if ($key > $largest_key) {
$largest_key = $key;
}
}
# $self->{distribution} = \%dist_hash;} |
| AUTHOR | Top |
| Dagitses, Michael << <clair at umich.edu> >> |
| BUGS | Top |
| Please report any bugs or feature requests to bug-clair-document at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=clairlib-dev. I will be notified, and then you will automatically be notified of progress on your bug as I make changes. |
| SUPPORT | Top |
You can find documentation for this module with the perldoc command.perldoc Clair::GenYou can also look for information at: |
| COPYRIGHT & LICENSE | Top |
| Copyright 2006 The University of Michigan, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |