Re: Re: InverseFunction of a CDF
- To: mathgroup at smc.vnet.net
- Subject: [mg102815] Re: [mg102807] Re: [mg102767] InverseFunction of a CDF
- From: Daniel Lichtblau <danl at wolfram.com>
- Date: Fri, 28 Aug 2009 00:44:42 -0400 (EDT)
- References: <200908261155.HAA11857@smc.vnet.net> <op.uzahb5ootgfoz2@bobbys-imac-2.local> <200908271038.GAA26125@smc.vnet.net>
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
- References:
- InverseFunction of a CDF
- From: "Christian Winzer" <cw420@cam.ac.uk>
- Re: InverseFunction of a CDF
- From: "Christian Winzer" <cw420@cam.ac.uk>
- InverseFunction of a CDF