|
NAMEMath::SymbolicX::Statistics::Distributions - Statistical DistributionsSYNOPSISuse Math::SymbolicX::Statistics::Distributions ':all'; ##################################################### # The following demonstrates the procedural interface # (included in :all) use Math::SymbolicX::Statistics::Distributions ':functions'; $dist = normal_distribution('mean', 'rmsd'); print $dist->value(mean => 5, rmsd => 2, x => 1); # similar: $dist = gauss_distribution('mean', 'rmsd'); # same as normal_distribution $dist = bivariate_normal_distribution( 'mean1', 'rmsd1', 'mean2', 'rmsd2', 'correlation ); # plug in any expression: (y*2 will be mean, z^3 root mean square deviation) $dist = normal_distribution('y*2', 'z^3'); print $dist->value(x => 0.5, y => 3, z => 0.2); # To generate the error function: (mean = 0; rmsd = 1) $dist = normal_distribution(0, 1); print $dist->value(x => 1); ######################################################### # The following demonstrates the parser/grammar interface # We'll do the exact same as above with the other interface. # (included in :all) use Math::SymbolicX::Statistics::Distributions ':grammar'; use Math::Symbolic qw/parse_from_string/; $dist = parse_from_string('normal()'); print $dist->value(mean => 5, rmsd => 2, x => 1); # similar: $dist = parse_from_string('gauss(mean, rmsd)'); # same as normal() $dist = parse_from_string( 'bivariate_normal(mean1, rmsd1,' .'mean2, rmsd2,' .'correlation )' ); # plug in any expression: (y*2 will be mean, z^3 root mean square deviation) $dist = parse_from_string('normal(y*2, z^3)'); print $dist->value(x => 0.5, y => 3, z => 0.2); # To generate the error function: (mean = 0; rmsd = 1) $dist = parse_from_string('normal(0, 1)'); print $dist->value(x => 1); # same works for the keywords 'boltzmann', 'bose', 'fermi' DESCRIPTIONThis module offers easy access to formulas for a few often-used distributions. For that, it uses the Math::Symbolic module which gives the user an opportunity to manufacture distributions to his liking.The module can be used in two styles: It has a procedural interface which is demonstrated in the first half of the synopsis. But it also features a wholly different interface: It can modify the Math::Symbolic parser so that you can use the distributions right inside strings that will be parsed as Math::Symbolic trees. This is demonstrated for very simple cases in the second half of the synopsis. All arguments in both interface styles are optional. Whichever expression is used instead of, for examle 'mean', is plugged into the formula for the distribution as a Math::Symbolic tree. Details on argument handling are explained below. Please see the section on Export for details on how to choose the interface style you want to use. The arguments for the grammar-interface version of the module follow the same concept as for the function interface which is described in Distributions in detail. The only significant difference is that the arguments must all be strings to be parsed as Math::Symbolic trees. There is one exception: If the string 'undef' is passed as one argument to the function, that string is converted to a real undef, but nevermind and see below. ExportBy default, the module does not export any functions and does not modify the Math::Symbolic parser. You have to explicitly request that does so using the usual Exporter semantics.If using the module without parameters ("use Math:SymbolicX::Statistics::Distributions;"), you can access the distributions via the fully qualified subroutine names such as "Math::SymbolicX::Statistics::Distributions::normal_distribution()". But that would be annoying, no? You can choose to export any of the distribution functions (see below) by specifying one or more function names: use Math::SymbolicX::Statistics::Distributions qw/gauss_distribution/; # then: $dist = gauss_distribution(...); You can also import all of them by using the ':functions' tag: use Math::SymbolicX::Statistics::Distributions qw/:functions/; ... Alternatively, you can choose to modify the Math::Symbolic parser by using any of the following keywords in the same way we used the function names above. normal_grammar gauss_grammar bivariate_normal_grammar cauchy_grammar boltzmann_grammar bose_grammar fermi_grammar To add all the keywords ("normal()", "gauss()", "bivariate_normal()", "cauchy()", "boltzmann()", "bose()", and "fermi()" to the grammar, you can specify ":grammar" instead. Finally, the module supports the exporter tag ":all" to both export all functions and add all keywords to the parser. DistributionsThe following is a list of distributions that can be generated using this module.
SEE ALSOHave a look at Math::Symbolic, Math::Symbolic::Parser, Math::SymbolicX::ParserExtensionFactory and all associated modules.New versions of this module can be found on http://steffen-mueller.net or CPAN. Details on several distributions implemented in the code can be found on the MathWorld site: Eric W. Weisstein. "Normal Distribution." From MathWorld -- A Wolfram Web Resource. http://mathworld.wolfram.com/NormalDistribution.html Eric W. Weisstein. "Bivariate Normal Distribution." From MathWorld -- A Wolfram Web Resource. http://mathworld.wolfram.com/BivariateNormalDistribution.html Eric W. Weisstein. "Cauchy Distribution." From MathWorld -- A Wolfram Web Resource. http://mathworld.wolfram.com/CauchyDistribution.html The Boltzmann, Bose, and Fermi distributions are discussed in detail in N.W. Ashcroft, N.D. Mermin. "Solid State Physics". Brooks/Cole, 1976 AUTHORSteffen Mueller, <symbolic-module at steffen-mueller dot net>COPYRIGHT AND LICENSECopyright (C) 2005, 2006 by Steffen MuellerThis library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.6.0 or, at your option, any later version of Perl 5 you may have available.
Visit the GSP FreeBSD Man Page Interface. |