MathGroup Archive 2009

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

Search the Archive

InverseFunction of a CDF

  • To: mathgroup at smc.vnet.net
  • Subject: [mg102767] InverseFunction of a CDF
  • From: "Christian Winzer" <cw420 at cam.ac.uk>
  • Date: Wed, 26 Aug 2009 07:55:06 -0400 (EDT)

Hello,

I am calculating the cumulated density function of a variable x based on the
variables m and z using the following code:

(* Distribution of the stochastic variable m*)
M = NormalDistribution[0, 1];
mPDF = PDF[M];
mCDF = CDF[M];

(* Weight of m in x*)
w = 0.5;

(* Distribution of the stochastic variable z*)
Z = NormalDistribution[0, 1];
zPDF = PDF[Z];
zCDF = CDF[Z];

(*This section calculates the distribution of x = w * m + z *)
(*Conditional cumulated density xCDFm[x,m] of the stochastic variable x
conditional on m *)
xCDFm = Evaluate[zCDF[(#1 - w * #2)/(Sqrt[1 - w^2])]] &;

(*Unconditional cumulated density xCDF[x] of the stochastic variable x *)
xCDF = NIntegrate[xCDFm[#1, m]* mPDF[m], {m, -\[Infinity], \[Infinity]}] &;


The calculation seems to work, because I can plot xCDF correctly.
But for some reason, I can not get the inverse function. I have tried 3
different ways:


In[78]:= 
x = InverseFunction[xCDF][#1] &;
Evaluate[x[0.5]]

Out[79]= 
InverseFunction[NIntegrate[xCDFm[#1, m] mPDF[m], {m, -\[Infinity],
\[Infinity]}] &][0.5]


In[80]:= 
Evaluate[Quantile[xCDF, 0.5]]

Out[81]= 
Quantile[NIntegrate[xCDFm[#1, m] mPDF[m], {m, -\[Infinity], \[Infinity]}] &,
0.5]


In[82]:=
Solve[xCDF[x] == 0.5, x]

During evaluation of In[73]:= NIntegrate::inumr: The integrand (E^(-(m^2/2))
(1+Erf[0.816497 (-0.5 m+((xCDF^(-1))[Slot[<<1>>]]&))]))/(2 Sqrt[2 \[Pi]])
has evaluated to non-numerical values for all sampling points in the region
with boundaries {{-\[Infinity],0.}}. >>

During evaluation of In[73]:= NIntegrate::inumr: The integrand (E^(-(m^2/2))
(1+Erf[0.816497 (-0.5 m+((xCDF^(-1))[Slot[<<1>>]]&))]))/(2 Sqrt[2 \[Pi]])
has evaluated to non-numerical values for all sampling points in the region
with boundaries {{-\[Infinity],0.}}. >>

During evaluation of In[73]:= NIntegrate::inumr: The integrand (E^(-(m^2/2))
(1+Erf[0.816497 (-0.5 m+((xCDF^(-1))[Slot[<<1>>]]&))]))/(2 Sqrt[2 \[Pi]])
has evaluated to non-numerical values for all sampling points in the region
with boundaries {{-\[Infinity],0.}}. >>

During evaluation of In[73]:= General::stop: Further output of
NIntegrate::inumr will be suppressed during this calculation. >>

During evaluation of In[73]:= Solve::ifun: Inverse functions are being used
by Solve, so some solutions may not be found; use Reduce for complete
solution information. >>

Out[83]= {}

In this particular example I know without calculation, that xCDF is the
CDF[NormalDistribution[0,Sqrt[1.25]]], however I want to use different
distributions for m and z in the future, and then I can't always tell the
distribution of x, so I will need to calculate it. Any ideas how I could do
that?

Thank you very much in advance and best wishes,
Christian






  • Prev by Date: Re: Viewing packages in mathematica
  • Next by Date: Re: Re: Recognizing finite groups in Mathematica 7
  • Previous by thread: Re: DynamicModule causing problems with Manipulate setter bar
  • Next by thread: Re: InverseFunction of a CDF