|
[Date Index]
[Thread Index]
[Author Index]
RE: Re: help in generating a gaussian random variable
- To: mathgroup at smc.vnet.net
- Subject: [mg35530] RE: [mg35502] Re: [mg35488] help in generating a gaussian random variable
- From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
- Date: Thu, 18 Jul 2002 03:06:13 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
> -----Original Message-----
> From: BobHanlon at aol.com [mailto:BobHanlon at aol.com]
> Sent: Wednesday, July 17, 2002 8:09 AM
> Subject: [mg35530] [mg35502] Re: [mg35488] help in generating a gaussian random
> variable
>
>
>
> In a message dated 7/16/02 5:50:43 AM, dsalman at itee.uq.edu.au writes:
>
> >I need to generate a Gaussian random variable y having mean
> =0 and variance
> >=x.
> >
> >The variance x is itself a gaussian random variable having a
> known mean
> >and
> >variance.
> >e.g. mean of x =5;
> >variance of x = 10;
> >
> >Can anyone suggest how to use this information to generate y ?
> >
>
> Needs["Statistics`NormalDistribution`"];
>
> data=RandomArray[
> NormalDistribution[0, Random[
> NormalDistribution[5, Sqrt[ 10]]]], {100}];
>
>
> Bob Hanlon
> Chantilly, VA USA
>
Bob,
sorry, but I'm wary of your proposed solution. This is because RandomArray
is an optimising function to speed up over Table Random.
A look into the package Statistics`ContinuousDistributions` reveals that the
arguments to NormalDistribution are evaluated only once. So the variance x
is not a random variable. A statistics test of
data2 = Table[
Random[NormalDistribution[0,
Random[NormalDistribution[5, Sqrt[10]]]]], {100}];
should reveal this. To make it simple for me: taking samples of 10001 events
respectively, and comparing the cumulants e.g.
Block[{$DisplayFunction = Identity},
ListPlot[
Take[Transpose[{Sort[#1], Range[Length[#1]]/Length[#1]}],
{1, -1, 100}],
PlotJoined -> True,
PlotStyle -> #2]] & @@@ {{data, {}}, {data2, Hue[.7]}} // Show
shows a great discrepancy. Perhaps you like to draw multiple samples of data
(not neccessarily of data2) to compare.
This also shows that the desired distribution is not a normal distribution
(when x is a random variable).
Even more revealing is to compare the distributions by eye view
GraphicsArray[
Block[{$DisplayFunction = Identity, step = 100, scale},
scale = step/Length[#1];
ListPlot[{Plus[##]/2, -scale/Subtract[##]} & @@@
Partition[Take[Sort[#1], {1, -1, step}], 2, 1],
PlotJoined -> True, PlotStyle -> #2,
PlotRange -> {{-20, 20}, {0, .2}}]] & @@@ {{data, {}}, {data2,
Hue[.7]}}] // Show
--
Hartmut
Prev by Date:
Re: Integration problem
Next by Date:
Re: Factoring question
Previous by thread:
RE: Re: help in generating a gaussian random variable
Next by thread:
RE: Re: help in generating a gaussian random variable
|