.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" 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" '' . ds C` . ds C' '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 >0, 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. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Distr 3pm" .TH Distr 3pm "2022-12-17" "perl v5.36.0" "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 $data = grandom(100)\->abs; \& \& 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 processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. .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 processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. .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 processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. .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 processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. .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 processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. .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 processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. .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 processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. .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 processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. .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 processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. .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 processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. .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 processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. .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 processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. .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 processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. .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 processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. .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 processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. .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 processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. .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 processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. .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 processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. .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 processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. .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 processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. .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 processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. .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 processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. .SS "pmf_poisson" .IX Subsection "pmf_poisson" .Vb 1 \& Signature: (x(); l(); float+ [o]p()) .Ve .PP Probability mass function for poisson distribution. Uses Stirling's formula for x > 85. .PP pmf_poisson processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. .SS "pmf_poisson_stirling" .IX Subsection "pmf_poisson_stirling" .Vb 1 \& Signature: (x(); l(); [o]p()) .Ve .PP 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. .PP pmf_poisson_stirling processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. .SS "pmf_poisson_factorial" .IX Subsection "pmf_poisson_factorial" .Vb 1 \& Signature: ushort x(); l(); float+ [o]p() .Ve .PP Probability mass function for poisson distribution. Input is limited to x < 170 to avoid \fBgsl_sf_fact()\fR overflow. .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 , David Mertens .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.