RE: help in generating a gaussian random variable
- To: mathgroup at smc.vnet.net
- Subject: [mg35512] RE: [mg35488] help in generating a gaussian random variable
- From: "DrBob" <majort at cox-internet.com>
- Date: Wed, 17 Jul 2002 02:09:02 -0400 (EDT)
- Reply-to: <drbob at bigfoot.com>
- Sender: owner-wri-mathgroup at wolfram.com
Maybe this is what you want. "count" will keep track of how many times Y is evaluated, which is very important: << Statistics`ContinuousDistributions` X = NormalDistribution[5, 10]; x := Random[X] count = 0; Y := (count++; NormalDistribution[0, Evaluate@x]) y := Random[Y] y count -6.07805 1 << Graphics`Graphics` Histogram[y & /@ Range[100]] 101 Histogram[RandomArray[Y, 100]] 102 The first Histogram argument draws 100 X samples and, for each of them, one Y sample. The second Histogram argument draws one X sample and then 100 Y samples. The second depicts a Gaussian variable; the first does not (too much kurtosis) -- but maybe it's what you want. z = y & /@ Range[100000]; #[z] & /@ {Mean, StandardDeviation, Skewness, Kurtosis} z = RandomArray[Y, 100000]; #[z] & /@ {Mean, StandardDeviation, Skewness, Kurtosis} {-0.0490017, 11.2665, 0.0387603, 9.00383} {-0.0808581, 20.4408, 0.0101782, 2.97761} Here's another output for the same input cell: {0.0359718, 11.1685, 0.0436788, 8.29863} {0.00507702, 13.7293, 0.00278272, 3.00732} The second method gives a variable variance, but the first does not. Bobby Treat -----Original Message----- From: Salman Durrani [mailto:dsalman at itee.uq.edu.au] To: mathgroup at smc.vnet.net Subject: [mg35512] [mg35488] help in generating a gaussian random variable 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