0
$\begingroup$

I have tried many times to plot a CDF from the following PDF code , But I failed to get that however I have used the command CumulantGeneratingfunction[, ] but it coudn't work , any Help ?and also the same with Histogram plot ?

 f[z_?NumericQ, \[Mu]_?NumericQ] := 
  NIntegrate[Sqrt[6]/Sqrt[2*Pi]Exp[-(z - \[Mu])^2/(Pi)
]* Erf[(z - \[Mu])/(\[Sigma] Sqrt[2*Pi])]* Erfi[(z - \[Mu])/(\[Sigma] Sqrt[2*Pi])], {\[Sigma], 1, \[Infinity]}]
pdfF[\[Mu]_?NumericQ] := PDF[ProbabilityDistribution[f[x, \[Mu]], {x, - \[Infinity], \[Infinity]}]]
With[{n = 5},
  Show[
      Plot[
        Labeled[pdfF[#1][z], Row[{"\[Mu] = ", Rationalize[#1]}], Above], {z, -5, 5},
     PlotRange -> All,
        PlotStyle -> #2] &
    @@@
      Rest[{#, Hue[#]} & /@ Subdivide[0., 1., n]],
  ImageSize -> Large]]
With[{n = 5}, NIntegrate[pdfF[#][z], {z, -5, 5}] & /@ (Range[n]/n)]
$\endgroup$
  • $\begingroup$ First, the integral of f is not 1, so it is not a properly defined PDF function (e.g. NIntegrate[f[z, 3], {z, -∞, ∞}] returns 1.01826); you need to introduce a normalization factor. Furthermore, your use of PDF[ProbabilityDistribution[f[x, μ], {x, -∞, ∞}]] is redundant: ProbabilityDistribution will generate a distribution assuming that its first argument is a well-defined PDF, normalized to 1. When you apply PDF to that, you just get f[x, μ] back (evaluate pdfF[2]), so using PDF[ProbabilityDistribution[f[...], ...]] is completely equivalent to using your own f. $\endgroup$ – MarcoB Dec 6 '19 at 15:58
  • $\begingroup$ I have a normalization to 0.98 is that accepted PDF ? $\endgroup$ – zeraoulia rafik Dec 6 '19 at 16:02
  • 1
    $\begingroup$ Close, but not quite. A probability density function's integral over the entire space should be guaranteed to be exactly equal to 1. $\endgroup$ – MarcoB Dec 6 '19 at 16:04
  • $\begingroup$ I have adjusted it now I have got 0.99 $\endgroup$ – zeraoulia rafik Dec 6 '19 at 16:24
  • $\begingroup$ @MarcoB , Pleas could u give me an answer below how i can plot CDF , I have normalized it to 1 , But am stiil unable to plot generating CDF from That PDF $\endgroup$ – zeraoulia rafik Dec 7 '19 at 20:46

Your Answer

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

Browse other questions tagged or ask your own question.