Maggie J. Xiong > PDL-Stats-0.6.3_3 > PDL::Stats::Distr

Download:
PDL-Stats-0.6.3_3.tar.gz

Annotate this POD

CPAN RT

Open  1
View/Report Bugs
Source   Latest Release: PDL-Stats-0.6.5

NAME ^

PDL::Stats::Distr -- parameter estimations and probability density functions for distributions.

DESCRIPTION ^

Parameter estimate is maximum likelihood estimate when there is closed form estimate, otherwise it is method of moments estimate.

SYNOPSIS ^

    use PDL::LiteF;
    use PDL::Stats::Distr;

      # do a frequency (probability) plot with fitted normal curve

    my ($xvals, $hist) = $data->hist;

      # turn frequency into probability
    $hist /= $data->nelem;

      # get maximum likelihood estimates of normal curve parameters
    my ($m, $v) = $data->mle_gaussian();

      # fitted normal curve probabilities
    my $p = $xvals->pdf_gaussian($m, $v);

    use PDL::Graphics::PGPLOT::Window;
    my $win = pgwin( Dev=>"/xs" );

    $win->bin( $hist );
    $win->hold;
    $win->line( $p, {COLOR=>2} );
    $win->close;

Or, play with different distributions with plot_distr :)

    $data->plot_distr( 'gaussian', 'lognormal' );
    my ($a, $b) = $data->mme_beta();

beta distribution. pdf: f(x; a,b) = 1/B(a,b) x^(a-1) (1-x)^(b-1)

probability density function for beta distribution. x defined on [0,1].

    my ($n, $p) = $data->mme_binomial;

binomial distribution. pmf: f(k; n,p) = (n k) p^k (1-p)^(n-k) for k = 0,1,2..n

probability mass function for binomial distribution.

    my $lamda = $data->mle_exp;

exponential distribution. mle same as method of moments estimate.

probability density function for exponential distribution.

    my ($shape, $scale) = $data->mme_gamma();

two-parameter gamma distribution

probability density function for two-parameter gamma distribution.

    my ($m, $v) = $data->mle_gaussian();

gaussian aka normal distribution. same results as $data->average and $data->var. mle same as method of moments estimate.

probability density function for gaussian distribution.

geometric distribution. mle same as method of moments estimate.

probability mass function for geometric distribution. x >= 0.

shifted geometric distribution. mle same as method of moments estimate.

probability mass function for shifted geometric distribution. x >= 1.

    my ($m, $v) = $data->mle_lognormal();

lognormal distribution. maximum likelihood estimation.

    my ($m, $v) = $data->mme_lognormal();

lognormal distribution. method of moments estimation.

probability density function for lognormal distribution. x > 0. v > 0.

    my ($r, $p) = $data->mme_nbd();

negative binomial distribution. pmf: f(x; r,p) = (x+r-1 r-1) p^r (1-p)^x for x=0,1,2...

probability mass function for negative binomial distribution.

    my ($k, $xm) = $data->mme_pareto();

pareto distribution. pdf: f(x; k,xm) = k xm^k / x^(k+1) for x >= xm > 0.

probability density function for pareto distribution. x >= xm > 0.

    my $lamda = $data->mle_poisson();

poisson distribution. pmf: f(x;l) = e^(-l) * l^x / x!

Probability mass function for poisson distribution. Uses Stirling's formula for x > 85.

Probability mass function for poisson distribution. Uses Stirling's formula for all values of the input. See http://en.wikipedia.org/wiki/Stirling's_approximation for more info.

pmf_poisson_factorial

  Signature: ushort x(); l(); float+ [o]p()

Probability mass function for poisson distribution. Input is limited to x < 170 to avoid gsl_sf_fact() overflow.

plot_distr

Plots data distribution. When given specific distribution(s) to fit, returns % ref to sum log likelihood and parameter values under fitted distribution(s). See FUNCTIONS above for available distributions.

Default options (case insensitive):

    MAXBN => 20, 
      # see PDL::Graphics::PGPLOT::Window for next options
    WIN   => undef,   # pgwin object. not closed here if passed
                      # allows comparing multiple distr in same plot
                      # set env before passing WIN
    DEV   => '/xs' ,  # open and close dev for plotting if no WIN
                      # defaults to '/png' in Windows
    COLOR => 1,       # color for data distr

Usage:

      # yes it threads :)
    my $data = grandom( 500, 3 )->abs;
      # ll on plot is sum across 3 data curves
    my ($ll, $pars)
      = $data->plot_distr( 'gaussian', 'lognormal', {DEV=>'/png'} );

      # pars are from normalized data (ie data / bin_size)
    print "$_\t@{$pars->{$_}}\n" for (sort keys %$pars);
    print "$_\t$ll->{$_}\n" for (sort keys %$ll);

DEPENDENCIES ^

GSL - GNU Scientific Library

SEE ALSO ^

PDL::Graphics::PGPLOT

PDL::GSL::CDF

AUTHOR ^

Copyright (C) 2009 Maggie J. Xiong <maggiexyz users.sourceforge.net>, David Mertens

All rights reserved. There is no warranty. You are allowed to redistribute this software / documentation as described in the file COPYING in the PDL distribution.

syntax highlighting: