MathGroup Archive 2011

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

Search the Archive

Re: Solve for parameters of a truncated normal distribution

  • To: mathgroup at smc.vnet.net
  • Subject: [mg122924] Re: Solve for parameters of a truncated normal distribution
  • From: "Dr. Wolfgang Hintze" <weh at snafu.de>
  • Date: Wed, 16 Nov 2011 04:46:25 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <j9tga2$n91$1@smc.vnet.net>

"paul" <paulvonhippel at yahoo.com> schrieb im Newsbeitrag 
news:j9tga2$n91$1 at smc.vnet.net...
> I'm trying to solve the following problem:
> X = TruncatedDistribution[{0, \[Infinity]},
>  NormalDistribution[\[Mu], \[Sigma]]]
> Solve[Mean[X] == 1 && Variance[X] == 1, {\[Mu], \[Sigma]}, Reals]
>
> I get an error message: "This system cannot be solved with the 
> methods
> available to Solve." It doesn't help if I replace Solve with NSolve.
>
> In case I've made a mistake in defining the problem, I should say 
> that
> I'm looking for the parameters of a normal distribution so that, if
> the normal is truncated on the left at zero, the result will be a
> truncated distribution whose mean and variance are both 1. It seems 
> to
> me Mathematica should be able to solve this, at least numerically.
>
> Many thanks for any suggestions.
>
>

Writing down the problem in explicit form I find a solution

mu = 0, sigma = 2 Sqrt[2/Pi]

But I don't know if there are more.

Here we dive into the details:

<< "Statistics`ContinuousDistributions`"

X = NormalDistribution[\[Mu], \[Sigma]]
    NormalDistribution[\[Mu], \[Sigma]]
Mean[X]
    \[Mu]
Variance[X]
    \[Sigma]^2

PDF[X, x]
    1/(E^((x - \[Mu])^2/(2*\[Sigma]^2))*(Sqrt[2*Pi]*\[Sigma]))

(* Y is the truncated distribution *)

Y = (1/2)*PDF[X, x]
    1/(E^((x - \[Mu])^2/(2*\[Sigma]^2))*(2*Sqrt[2*Pi]*\[Sigma]))

(* the first few moments of Y *)

m0 = Integrate[Y, {x, 0, Infinity}, Assumptions -> {\[Sigma] > 0, \[Mu] 
 > 0}]
    (1/4)*(1 + Erf[\[Mu]/(Sqrt[2]*\[Sigma])])

m1 = Integrate[x*Y, {x, 0, Infinity}, Assumptions -> {\[Sigma] > 0, 
\[Mu] > 0}]/m0
    (\[Mu] + (Sqrt[2/Pi]*\[Sigma])/E^(\[Mu]^2/(2*\[Sigma]^2)) +
    \[Mu]*Erf[\[Mu]/(Sqrt[2]*\[Sigma])])/
    (1 + Erf[\[Mu]/(Sqrt[2]*\[Sigma])])

m2 = Integrate[x^2*Y, {x, 0, Infinity}, Assumptions -> {\[Sigma] > 0, 
\[Mu] > 0}]/m0
    (4*((\[Mu]*\[Sigma])/(E^(\[Mu]^2/(2*\[Sigma]^2))*(2*Sqrt[2*Pi])) +
    (1/4)*(\[Mu]^2 + \[Sigma]^2)*
    (1 + Erf[\[Mu]/(Sqrt[2]*\[Sigma])])))/
    (1 + Erf[\[Mu]/(Sqrt[2]*\[Sigma])])

s2 = Simplify[m2 - m1^2]
    (\[Sigma]*((-E^(-(\[Mu]^2/(2*\[Sigma]^2))))*Sqrt[2/Pi]*\[Mu] + 
\[Sigma] -
    (2*\[Sigma])/(E^(\[Mu]^2/\[Sigma]^2)*Pi) +
    ((-E^(-(\[Mu]^2/(2*\[Sigma]^2))))*Sqrt[2/Pi]*\[Mu] + 2*\[Sigma])*
    Erf[\[Mu]/(Sqrt[2]*\[Sigma])] +
    \[Sigma]*Erf[\[Mu]/(Sqrt[2]*\[Sigma])]^2))/
    (1 + Erf[\[Mu]/(Sqrt[2]*\[Sigma])])^2

(* solving with Solve or NSolve does not lead to a result *)

NSolve[m1 == 1 && s2 == 1, {\[Mu], \[Sigma]}]
    $Aborted

(* now setting mu -> 0 *)

(m1 /. \[Mu] -> 0) == 1
    Sqrt[2/Pi]*\[Sigma] == 1
(s2 /. \[Mu] -> 0) == 1
    \[Sigma]*(\[Sigma] - (2*\[Sigma])/Pi) == 1

(* ... and solving for sigma gives the result *)

Solve[Sqrt[2/Pi]*\[Sigma] == 1 && \[Sigma]*(\[Sigma] - (2*\[Sigma])/Pi) 
==
1]
    {{\[Sigma] -> 2*Sqrt[2/Pi]}}

(* The case mu != 0 can be studied graphically plotting the two 
quantities m1 and s2 versus sigma *)

(* I could not find a point of intersection at m1 == s2 == 1 *)

Regards,
Wolfgang 




  • Prev by Date: Re: Solve for parameters of a truncated normal distribution
  • Next by Date: Help needed - Mathematica code
  • Previous by thread: Re: Solve for parameters of a truncated normal distribution
  • Next by thread: Re: Solve for parameters of a truncated normal distribution