Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

The Taylor series (about 0) for the cumulative normal distribution has coefficients:

g[i_] := Piecewise[{{Sqrt[Pi/2], i == 0}, {(-1/2)^((i - 1)/2)/(((i - 1)/2)!*i), Mod[i, 2] == 1}}]/Sqrt[2*Pi]

However,

Sum[g[i]*x^i,{i,0,Infinity}]

gives $e^x$ and not the $\frac{1}{2} + \frac{1}{2} Erf(\frac{x}{\sqrt{2}})$ expected.

When I

Plot[Sum[g[i]*x^i, {i, 0, 20}], {x, -5, 5}]

I get something looking like an exponential (not expected). But when I

Plot[Evaluate[Sum[g[i]*x^i, {i, 0, 20}]], {x, -5, 5}]

I get something looking like the cumulative normal distribution (expected). Trying to understand the different plots, I looked at

{Limit[Sum[g[i]*x^i, {i, 0, n}], n -> 3], Sum[g[i]*x^i, {i, 0, 3}]}

Which gave $\left\{\frac{e^x \Gamma (4,x)}{6},-\frac{x^3}{6 \sqrt{2 \pi }}+\frac{x}{\sqrt{2 \pi }}+\frac{1}{2}\right\}$ - the choice of n=3 is just for tidiness, similar results hold for all n (that I tried). These are clearly not equal as substituting $x\to 0$ gives $\{1,\frac{1}{2}\}$.

This, presumably, explains why I am getting the incorrect answer for the infinite sum and different plot results depending on the placement of the evaluate. Is there an explanation as to why I get different results with/without the limit and how to work around it (in the infinite sum case)?

The motivation is that I am trying to combine these coefficients in other infinite sums (corresponding to cumulative distribution of a sum of Gaussians centered at different positions) and it is giving results that differ from the series expansion I otherwise would obtain (using Series).

The above was tested on Mathematica 9.01 on Linux.

EDIT Turns out that the sum doesn't evaluate on Mathematica 9.01, there was traces of previous definitions lying around that caused it to evaluate when it shouldn't have. Solution is to avoid the piecewise definition and explicitly only sum the odd terms.

share|improve this question
1  
on V 9.01 on windows, the sum does not evaluate. I copied what you had there. screen shot: !Mathematica graphics it always helps to say what version and platform you are using. –  Nasser Sep 11 '13 at 7:57
    
Hm, strangely Mathematica does simplify Sum[Piecewise[{{1, Mod[i, 2] == 0}}], {i, 0, n}] but not Sum[Piecewise[{{i, Mod[i, 2] == 0}}], {i, 0, n}]. –  Jacob Akkerboom Sep 11 '13 at 10:12
    
@Nasser Thanks for the comment, I've updated the question saying that it was tested on Mathematica 9.01 on Linux. –  Joel Bosveld Sep 11 '13 at 12:12
1  
On my Linux, V 9.0.1 I've got the same result as Nasser. Do you perform it on a fresh kernel? –  ybeltukov Sep 11 '13 at 12:43
    
On my Linux, v8.0 the indefinite same does not evaluate either. –  Eckhard Sep 11 '13 at 13:34
show 1 more comment

1 Answer

up vote 0 down vote accepted

Maybe not a direct answer to your question, but you can simplify the coefficients and be careful in the summation :

myg2[i_] = (-1/2)^((i - 1)/2)/(((i - 1)/2)!*i)/Sqrt[2*Pi]

1/2 + Sum[myg2[2 i + 1] x^(2 i + 1), {i, 0, Infinity}]
(* 1/2 + 1/2 Erf[x/Sqrt[2]] *)
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.