更改

跳到导航 跳到搜索
删除2,817字节 、 2021年11月14日 (日) 17:16
第1,953行: 第1,953行:       −
=== ''' Evaluating the Poisson distribution 计算泊松分布'''===
+
===计算泊松分布===
   −
Computing <math>P(k;\lambda)</math> for given <math>k</math> and <math>\lambda</math> is a trivial task that can be accomplished by using the standard definition of <math>P(k;\lambda)</math> in terms of exponential, power, and factorial functions. However, the conventional definition of the Poisson distribution contains two terms that can easily overflow on computers: λ<sup>''k''</sup> and ''k''!. The fraction of λ<sup>''k''</sup> to ''k''! can also produce a rounding error that is very large compared to ''e''<sup>−λ</sup>, and therefore give an erroneous result. For numerical stability the Poisson probability mass function should therefore be evaluated as
     −
Computing <math>P(k;\lambda)</math> for given <math>k</math> and <math>\lambda</math> is a trivial task that can be accomplished by using the standard definition of <math>P(k;\lambda)</math> in terms of exponential, power, and factorial functions. However, the conventional definition of the Poisson distribution contains two terms that can easily overflow on computers: λ<sup>k</sup> and k!. The fraction of λ<sup>k</sup> to k! can also produce a rounding error that is very large compared to e<sup>−λ</sup>, and therefore give an erroneous result. For numerical stability the Poisson probability mass function should therefore be evaluated as
+
计算<math>P(k;\lambda)</math>对于给定的<math>k</math><math>\lambda</math>是一项琐碎的任务,可以通过使用<math>P(k;\lambda)</math>的标准定义来完成,包括指数函数、幂函数和阶乘函数。然而,传统上对泊松分布的定义包含了两个容易在计算机上溢出的术语: λ<sup>''k''</sup>!和 ''k''。分数λ<sup>''k''</sup> 到''k''!也可能产生舍入误差,与''e''<sup>−λ</sup>相比,舍入误差非常大,因此给出错误的结果。因此,对于数值稳定性来说,泊松概率质量函数应该被评估为
 
  −
计算 < math > p (k; lambda) </math > 对于给定的 < math > k </math > 和 < math > lambda </math > 是一项琐碎的任务,可以通过使用 < math > p (k; lambda) </math > 的标准定义来完成,包括指数函数、幂函数和阶乘函数。然而,传统上对泊松分布的定义包含了两个容易在计算机上溢出的术语: < sup > k </sup > 和 k。分数 < sup > k </sup > 到 k!也可能产生舍入误差,与 e < sup >-</sup > 相比,舍入误差非常大,因此给出错误的结果。因此,对于数值稳定性来说,泊松概率质量函数应该被评估为
  −
  --[[用户:fairywang|fairywang]]([[用户讨论:fairywang|讨论]])  【审校】“泊松分布”改为“泊松分布”
      
:<math>\!f(k; \lambda)= \exp \left[ k\ln \lambda  - \lambda  - \ln \Gamma (k+1) \right],</math>
 
:<math>\!f(k; \lambda)= \exp \left[ k\ln \lambda  - \lambda  - \ln \Gamma (k+1) \right],</math>
   −
<math>\!f(k; \lambda)= \exp \left[ k\ln \lambda  - \lambda  - \ln \Gamma (k+1) \right],</math>
  −
  −
= exp left [ k ln lambda-lambda-ln Gamma (k + 1) right ] ,</math >
  −
  −
which is mathematically equivalent but numerically stable. The natural logarithm of the [[Gamma function]] can be obtained using the <code>lgamma</code> function in the [[C (programming language)|C]] standard library (C99 version) or [[R (programming language)|R]], the <code>gammaln</code> function in [[MATLAB]] or [[SciPy]], or the <code>log_gamma</code> function in [[Fortran]] 2008 and later.
  −
  −
which is mathematically equivalent but numerically stable. The natural logarithm of the Gamma function can be obtained using the <code>lgamma</code> function in the C standard library (C99 version) or R, the <code>gammaln</code> function in MATLAB or SciPy, or the <code>log_gamma</code> function in Fortran 2008 and later.
  −
  −
这在数学上是等价的,但在数值上是稳定的。函数的自然对数可以使用 c 标准库(C99版本)中的 < code > lgamma </code > 函数或 r,MATLAB 或 SciPy 中的 < code > gammaln </code > 函数,或 Fortran 2008及更高版本中的 < code > log _ Gamma </code > 函数来获得。
      +
这在数学上是等价的,但在数值上是稳定的。函数的自然对数可以使用 c 标准库(C99版本)中的<code>lgamma</code>函数或 R,MATLAB 或 SciPy 中的 <code>gammaln</code>函数,或 Fortran 2008及更高版本中的<code>log_gamma</code>函数来获得。
      −
Some computing languages provide built-in functions to evaluate the Poisson distribution, namely
+
一些计算语言提供了''' 内置函数来计算泊松分布
   −
Some computing languages provide built-in functions to evaluate the Poisson distribution, namely
+
* R语言:function <code>dpois(x, lambda)</code>;
   −
一些计算语言提供了''' 内置函数Built-in functions'''来评估泊松分布
+
* Microsoft Excel:function <code>POISSON( x, mean, cumulative)</code>, with a flag to specify the cumulative distribution;
  --[[用户:fairywang|fairywang]]([[用户讨论:fairywang|讨论]])  【审校】“泊松分布”改为“泊松分布”
  −
* [[R (programming language)|R]]: function <code>dpois(x, lambda)</code>;
     −
* [[Microsoft Excel|Excel]]: function <code>POISSON( x, mean, cumulative)</code>, with a flag to specify the cumulative distribution;
+
* Mathematica:单变量泊松分布为<code>PoissonDistribution[<math>\lambda</math>]</code>,<ref name="WLPoissonRefPage">{{cite web |url = http://reference.wolfram.com/language/ref/PoissonDistribution.html |title = Wolfram Language: PoissonDistribution reference page |website = wolfram.com |access-date = 2016-04-08 }}</ref> ,二元泊松分布为<code>MultivariatePoissonDistribution[<math>\theta_{12}</math>,{ <math>\theta_1 - \theta_{12}</math>, <math>\theta_2 - \theta_{12}</math>}]</code>.<ref name="WLMvPoissonRefPage">{{cite web |url = http://reference.wolfram.com/language/ref/MultivariatePoissonDistribution.html |title = Wolfram Language: MultivariatePoissonDistribution reference page |website = wolfram.com |access-date = 2016-04-08 }}</ref>
   −
* [[Mathematica]]: univariate Poisson distribution as <code>PoissonDistribution[<math>\lambda</math>]</code>,<ref name="WLPoissonRefPage">{{cite web |url = http://reference.wolfram.com/language/ref/PoissonDistribution.html |title = Wolfram Language: PoissonDistribution reference page |website = wolfram.com |access-date = 2016-04-08 }}</ref> bivariate Poisson distribution as <code>MultivariatePoissonDistribution[<math>\theta_{12}</math>,{ <math>\theta_1 - \theta_{12}</math>, <math>\theta_2 - \theta_{12}</math>}]</code>,.<ref name="WLMvPoissonRefPage">{{cite web |url = http://reference.wolfram.com/language/ref/MultivariatePoissonDistribution.html |title = Wolfram Language: MultivariatePoissonDistribution reference page |website = wolfram.com |access-date = 2016-04-08 }}</ref>
+
<br>
    
===从泊松分布中抽取随机量===
 
===从泊松分布中抽取随机量===
7,129

个编辑

导航菜单