MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: InverseFunction of a CDF


Christian Winzer wrote:
> Thank you for the quick response!
> I have replaced the corresponding lines in the example with the code you sent.
> To be on the safe side I have also restarted the kernel before the evaluation.
> However, it still does not work :
> NSolve returns the rule {{x->xCDF^(-1)[0.5]}} but I can't get a numerical
> value for this x.
> If I replace y=x/.% that does not do the job and neither if I ask for the
> numerical value thereof via 
> N[y[[1]]]. 
> The plots are also empty..
> 
> I have attached the adjusted code including the output below.
> Thank you for your help and best wishes!
> Christian
> [...]

Use FindRoot, not NSolve (which is meant for polynomial equations). One 
way to do this is indicated below.

xCDF2[x_?NumberQ] :=
  NIntegrate[xCDFm[x, m]*mPDF[m], {m, -\[Infinity], \[Infinity]}]

invertCDF[dist_, val_, start_: 0.01] /; 0 <= val <= 1 :=
   Module[{x}, x /. FindRoot[dist[x] == val, {x, start}]]

In[104]:= invertCDF[xCDF2, .4]
Out[104]= -0.253347

Daniel Lichtblau
Wolfram Research


  • Prev by Date: RE: Re: Import using Button( GUI)
  • Next by Date: Re: work only with Performance->Speed
  • Previous by thread: Re: InverseFunction of a CDF
  • Next by thread: Re: InverseFunction of a CDF