Strange statistics function integration
- To: mathgroup at smc.vnet.net
- Subject: [mg59545] Strange statistics function integration
- From: Erich Neuwirth <erich.neuwirth at univie.ac.at>
- Date: Fri, 12 Aug 2005 00:07:48 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
I am experiencing some very strage effects, and in effect errors,
with the continuous distributions.
Here is my code
<<Statistics`ContinuousDistributions`
PosterioriWithNormalProb1[mu_, sigma_][n_, k_] :=
Binomial[n, k]*Integrate[x^k*(1 -
x)^(n - k)*PDF[NormalDistribution[mu,
sigma], x], {x, -Infinity,Infinity}]
PosterioriWithNormalProb2[mu_,sigma_][n_,k_]:=
Binomial[n,k]*Assuming[Element[
sigma1,Reals] && sigma1>0 ,Integrate[
x^k*(1-x)^(n-k)*PDF[NormalDistribution[mu1,sigma1],x],{x,-
Infinity,Infinity}]]/.{mu1->mu,sigma1->sigma}
The difference between these two functions seems to be that
in the first case integration is done with the symbolic constants
replaced by numerical values to be substituted before integration, and
in the second case this substitution happens only after integration.
Now, the following happens:
In[78]:=
PosterioriWithNormalProb1[0.5,0.1][8,0]
From In[78]:=
Integrate::gener: Unable to check convergence
Out[78]=
0.0096998
In[79]:=
PosterioriWithNormalProb2[0.5,0.1][8,0]
Out[79]=
0.0096998
which seems ok.
However:
In[81]:=
PosterioriWithNormalProb1[0.5,0.001][8,0]
From In[81]:=
Integrate::gener: Unable to check convergence
Out[81]=
0.00780941
In[80]:=
PosterioriWithNormalProb2[0.5,0.001][8,0]
Out[80]=
0.00390669
In this example, the second result is correct, the first one is wrong.
Since Mathematica can solve the integration problem
with symbolic parameters, it is strange that the warning appears
when concrete numerical paramater are used during integration.
It is also strange that the problem only occurs for some values of sigma.
Can anybody help me understanding what is happening here?
Erich Neuwirth