.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Distr 3pm" .TH Distr 3pm "2012-06-04" "perl v5.14.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" PDL::Stats::Distr \-\- parameter estimations and probability density functions for distributions. .SH "DESCRIPTION" .IX Header "DESCRIPTION" Parameter estimate is maximum likelihood estimate when there is closed form estimate, otherwise it is method of moments estimate. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& 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; .Ve .PP Or, play with different distributions with \fBplot_distr\fR :) .PP .Vb 1 \& $data\->plot_distr( \*(Aqgaussian\*(Aq, \*(Aqlognormal\*(Aq ); .Ve .SH "FUNCTIONS" .IX Header "FUNCTIONS" .SS "mme_beta" .IX Subsection "mme_beta" .Vb 1 \& Signature: (a(n); float+ [o]alpha(); float+ [o]beta()) .Ve .PP .Vb 1 \& my ($a, $b) = $data\->mme_beta(); .Ve .PP beta distribution. pdf: f(x; a,b) = 1/B(a,b) x^(a\-1) (1\-x)^(b\-1) .PP mme_beta does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. .SS "pdf_beta" .IX Subsection "pdf_beta" .Vb 1 \& Signature: (x(); a(); b(); float+ [o]p()) .Ve .PP probability density function for beta distribution. x defined on [0,1]. .PP pdf_beta does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. .SS "mme_binomial" .IX Subsection "mme_binomial" .Vb 1 \& Signature: (a(n); int [o]n_(); float+ [o]p()) .Ve .PP .Vb 1 \& my ($n, $p) = $data\->mme_binomial; .Ve .PP binomial distribution. pmf: f(k; n,p) = (n k) p^k (1\-p)^(n\-k) for k = 0,1,2..n .PP mme_binomial does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. .SS "pmf_binomial" .IX Subsection "pmf_binomial" .Vb 1 \& Signature: (ushort x(); ushort n(); p(); float+ [o]out()) .Ve .PP probability mass function for binomial distribution. .PP pmf_binomial does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. .SS "mle_exp" .IX Subsection "mle_exp" .Vb 1 \& Signature: (a(n); float+ [o]l()) .Ve .PP .Vb 1 \& my $lamda = $data\->mle_exp; .Ve .PP exponential distribution. mle same as method of moments estimate. .PP mle_exp does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. .SS "pdf_exp" .IX Subsection "pdf_exp" .Vb 1 \& Signature: (x(); l(); float+ [o]p()) .Ve .PP probability density function for exponential distribution. .PP pdf_exp does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. .SS "mme_gamma" .IX Subsection "mme_gamma" .Vb 1 \& Signature: (a(n); float+ [o]shape(); float+ [o]scale()) .Ve .PP .Vb 1 \& my ($shape, $scale) = $data\->mme_gamma(); .Ve .PP two-parameter gamma distribution .PP mme_gamma does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. .SS "pdf_gamma" .IX Subsection "pdf_gamma" .Vb 1 \& Signature: (x(); a(); t(); float+ [o]p()) .Ve .PP probability density function for two-parameter gamma distribution. .PP pdf_gamma does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. .SS "mle_gaussian" .IX Subsection "mle_gaussian" .Vb 1 \& Signature: (a(n); float+ [o]m(); float+ [o]v()) .Ve .PP .Vb 1 \& my ($m, $v) = $data\->mle_gaussian(); .Ve .PP gaussian aka normal distribution. same results as \f(CW$data\fR\->average and \f(CW$data\fR\->var. mle same as method of moments estimate. .PP mle_gaussian does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. .SS "pdf_gaussian" .IX Subsection "pdf_gaussian" .Vb 1 \& Signature: (x(); m(); v(); float+ [o]p()) .Ve .PP probability density function for gaussian distribution. .PP pdf_gaussian does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. .SS "mle_geo" .IX Subsection "mle_geo" .Vb 1 \& Signature: (a(n); float+ [o]p()) .Ve .PP geometric distribution. mle same as method of moments estimate. .PP mle_geo does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. .SS "pmf_geo" .IX Subsection "pmf_geo" .Vb 1 \& Signature: (ushort x(); p(); float+ [o]out()) .Ve .PP probability mass function for geometric distribution. x >= 0. .PP pmf_geo does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. .SS "mle_geosh" .IX Subsection "mle_geosh" .Vb 1 \& Signature: (a(n); float+ [o]p()) .Ve .PP shifted geometric distribution. mle same as method of moments estimate. .PP mle_geosh does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. .SS "pmf_geosh" .IX Subsection "pmf_geosh" .Vb 1 \& Signature: (ushort x(); p(); float+ [o]out()) .Ve .PP probability mass function for shifted geometric distribution. x >= 1. .PP pmf_geosh does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. .SS "mle_lognormal" .IX Subsection "mle_lognormal" .Vb 1 \& Signature: (a(n); float+ [o]m(); float+ [o]v()) .Ve .PP .Vb 1 \& my ($m, $v) = $data\->mle_lognormal(); .Ve .PP lognormal distribution. maximum likelihood estimation. .PP mle_lognormal does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. .SS "mme_lognormal" .IX Subsection "mme_lognormal" .Vb 1 \& Signature: (a(n); float+ [o]m(); float+ [o]v()) .Ve .PP .Vb 1 \& my ($m, $v) = $data\->mme_lognormal(); .Ve .PP lognormal distribution. method of moments estimation. .PP mme_lognormal does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. .SS "pdf_lognormal" .IX Subsection "pdf_lognormal" .Vb 1 \& Signature: (x(); m(); v(); float+ [o]p()) .Ve .PP probability density function for lognormal distribution. x > 0. v > 0. .PP pdf_lognormal does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. .SS "mme_nbd" .IX Subsection "mme_nbd" .Vb 1 \& Signature: (a(n); float+ [o]r(); float+ [o]p()) .Ve .PP .Vb 1 \& my ($r, $p) = $data\->mme_nbd(); .Ve .PP negative binomial distribution. pmf: f(x; r,p) = (x+r\-1 r\-1) p^r (1\-p)^x for x=0,1,2... .PP mme_nbd does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. .SS "pmf_nbd" .IX Subsection "pmf_nbd" .Vb 1 \& Signature: (ushort x(); r(); p(); float+ [o]out()) .Ve .PP probability mass function for negative binomial distribution. .PP pmf_nbd does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. .SS "mme_pareto" .IX Subsection "mme_pareto" .Vb 1 \& Signature: (a(n); float+ [o]k(); float+ [o]xm()) .Ve .PP .Vb 1 \& my ($k, $xm) = $data\->mme_pareto(); .Ve .PP pareto distribution. pdf: f(x; k,xm) = k xm^k / x^(k+1) for x >= xm > 0. .PP mme_pareto does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. .SS "pdf_pareto" .IX Subsection "pdf_pareto" .Vb 1 \& Signature: (x(); k(); xm(); float+ [o]p()) .Ve .PP probability density function for pareto distribution. x >= xm > 0. .PP pdf_pareto does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. .SS "mle_poisson" .IX Subsection "mle_poisson" .Vb 1 \& Signature: (a(n); float+ [o]l()) .Ve .PP .Vb 1 \& my $lamda = $data\->mle_poisson(); .Ve .PP poisson distribution. pmf: f(x;l) = e^(\-l) * l^x / x! .PP mle_poisson does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. .SS "pmf_poisson" .IX Subsection "pmf_poisson" .Vb 1 \& Signature: (ushort x(); l(); float+ [o]p()) .Ve .PP probability mass function for poisson distribution. .PP pmf_poisson does handle bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. .SS "plot_distr" .IX Subsection "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 \s-1FUNCTIONS\s0 above for available distributions. .PP Default options (case insensitive): .PP .Vb 8 \& 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 => \*(Aq/xs\*(Aq , # open and close dev for plotting if no WIN \& # defaults to \*(Aq/png\*(Aq in Windows \& COLOR => 1, # color for data distr .Ve .PP Usage: .PP .Vb 5 \& # yes it threads :) \& my $data = grandom( 500, 3 )\->abs; \& # ll on plot is sum across 3 data curves \& my ($ll, $pars) \& = $data\->plot_distr( \*(Aqgaussian\*(Aq, \*(Aqlognormal\*(Aq, {DEV=>\*(Aq/png\*(Aq} ); \& \& # pars are from normalized data (ie data / bin_size) \& print "$_\et@{$pars\->{$_}}\en" for (sort keys %$pars); \& print "$_\et$ll\->{$_}\en" for (sort keys %$ll); .Ve .SH "DEPENDENCIES" .IX Header "DEPENDENCIES" \&\s-1GSL\s0 \- \s-1GNU\s0 Scientific Library .SH "SEE ALSO" .IX Header "SEE ALSO" PDL::Graphics::PGPLOT .PP \&\s-1PDL::GSL::CDF\s0 .SH "AUTHOR" .IX Header "AUTHOR" Copyright (C) 2009 Maggie J. Xiong .PP All rights reserved. There is no warranty. You are allowed to redistribute this software / documentation as described in the file \s-1COPYING\s0 in the \s-1PDL\s0 distribution.