MathGroup Archive 2002

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

Search the Archive

Re: help in generating a gaussian random variable

  • To: mathgroup at smc.vnet.net
  • Subject: [mg35606] Re: help in generating a gaussian random variable
  • From: "Christos Argyropoulos" <chrisarg at med.upatras.gr>
  • Date: Mon, 22 Jul 2002 02:11:07 -0400 (EDT)
  • References: <ah24b6$r2l$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

The following should do the trick :


Needs["Statistics`ContinuousDistributions`"];
Needs["Graphics`Graphics`"];
NormalDeviate[y_, mx_, vx_, n_] :=
  Module[{t}, t = Abs /@ RandomArray[NormalDistribution[mx, Sqrt[vx]], n];
    Table[Random[NormalDistribution[y, Sqrt[t[[i]]]]], {i, 1, n}]]

Histogram[NormalDeviate[0, 50, 50, 10000]]

Explation :

1) Load the continuous Distrbutions and graphics modules

2) Function NormalDeviate returns a list of n random numbers ~ N(y,
N(mx,vx) )

3) Histogram plots everything

"Salman Durrani" <dsalman at itee.uq.edu.au> wrote in message
news:ah24b6$r2l$1 at smc.vnet.net...
> Hi
>
> 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 ?
>
> thanks
>
> Salman
>
>
>
>




  • Prev by Date: RE: Beep
  • Next by Date: RE: Beep
  • Previous by thread: RE: RE: Re: help in generating a gaussian random variable
  • Next by thread: Re: help in generating a gaussian random variable