2
$\begingroup$

I would like to calculate the distribution function from the characteristic function. There is a formula given as

$$F_X(x)=\frac{1}{2}+\frac{1}{2\pi}\int_{0}^\infty \frac{e^{i w x}\phi(-w)-e^{-i w x}\phi(w)}{i w}\mbox{d}w$$ Actually, I want to evaluate $F_X(x)$ at some real number $b<0$. I wrote some codes in Mathematica with unfortunately no success. The codes give some results but they seem to be incorrect.

Here are my codes:

opts = {Method -> {Automatic, "SymbolicProcessing" -> None}, AccuracyGoal -> 8}
b = -2;
f1[x_] := PDF[NormalDistribution[2, 2], x]
ff1[\[Omega]_] := InverseFourierTransform[f1[x], x, \[Omega]]
qn1 =1/2 + 1/(2*Pi) NIntegrate[(Exp[I \[Omega] b]*ff1[-\[Omega]] -Exp[-I \[Omega] b]*ff1[\[Omega]])/(I \[Omega]), {\[Omega], 0,Infinity}, Evaluate@opts]
NIntegrate[f1[x], {x, -Infinity, b}]

What I expect is $qn1$ to be equal to the last line of my code. But it just $0$. I cannot see the problem. Perhaps someone can?

Thanks in advance

$\endgroup$
6
$\begingroup$

This is already bult into Mathematica

$Assumptions = {s > 0};

dist = NormalDistribution[m, s];

pdf[x_] = PDF[dist, x];

cf[w_] = CharacteristicFunction[dist, w];

pdf[x] == InverseFourierTransform[cf[w], w, x,
   FourierParameters -> {1, 1}] // Simplify

True

cf[w] == FourierTransform[pdf[x], x, w,
   FourierParameters -> {1, 1}] == 
  Expectation[Exp[I w x], x \[Distributed] dist] //
 Simplify

True

EDITED:

(cdf[x_] = Integrate[pdf[t], {t, -Infinity, x}]) ==
  CDF[dist, x] // Simplify

True

For a specific example of deriving the PDF from the characteristic function

dist = NormalDistribution[2, 2];

cf[w_] = CharacteristicFunction[dist, w];

(pdf[x_] = 
    InverseFourierTransform[cf[w], w, x, FourierParameters -> {1, 1}]) == 
  PDF[dist, x] //
 Simplify

True

(cdf[x_] = Integrate[pdf[t], {t, -Infinity, x}]) ==
  CDF[dist, x] // FullSimplify

True

pdf /@ Range[-4., 8., 2.]

{0.00221592, 0.0269955, 0.120985, 0.199471, 0.120985, 0.0269955, 0.00221592}

Plot[pdf[x], {x, -4, 8}]

enter image description here

cdf /@ Range[-4., 8., 2.]

{0.0013499, 0.0227501, 0.158655, 0.5, 0.841345, 0.97725, 0.99865}

Plot[cdf[x], {x, -4, 8}]

enter image description here

$\endgroup$
  • $\begingroup$ It seems I get $1/2$ for all $x$ not only for $x=-2$. I tried to draw $F_X$ for the given formula and mathematica gave me a constant line on $y=0.5$. $\endgroup$ – Seyhmus Güngören Jun 21 '14 at 21:52
  • $\begingroup$ Specific example added above to demonstrate clearly that this works. $\endgroup$ – Bob Hanlon Jun 22 '14 at 5:25
  • $\begingroup$ Thank you. The problem was about the Fourier parameters, which should have been chosen as $(1,1)$. $\endgroup$ – Seyhmus Güngören Jun 22 '14 at 11:11
4
$\begingroup$
Clear["Global`*"]
b = -2;
f1[x_] := Evaluate@PDF[NormalDistribution[2, 2], x];
ff1[\[Omega]_] := Evaluate@InverseFourierTransform[f1[x], x, \[Omega]];
f1[x]
ff1[x]
(Exp[I \[Omega] b]*ff1[-\[Omega]] - 
   Exp[-I \[Omega] b]*ff1[\[Omega]])/(I \[Omega]) // Simplify

enter image description here

$\endgroup$
  • $\begingroup$ Thank you very much for the answer. I used "Evaluate@" so that I can draw a figure out of this formulation. $\endgroup$ – Seyhmus Güngören Jun 22 '14 at 11:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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