[precision of random numbers] - A New Kind of Science: The NKS ForumA New Kind of Science: The NKS Forum
Pages:1
precision of random numbers
(Click here to view the original thread with full colors/images)
Posted by: cele
Hi there!
I have a question regarding the precision of normal (gaussian)-distributed random numbers.
I generate a set of N normal-distributed random numbers (centered around Xo and with standard deviation equal to S) with the following commands (and in this way the numbers have Machine Precision) :
<< Statistics`ContinuousDistributions`
dist = NormalDistribution[Xo, S];
freq = Table[Random[dist], {N}];
then I set their precision (or accuracy) to be 100 with the following command:
freq = SetAccuracy[freq, 100];
Do you know if it is possible to set their precision directly (as soon as they are generated) ? This is possible with uniformly random numbers using the command (N numbers uniformly distributed between a and b with precision 100):
Table[Random[Real, {a, b}, 100], {N}];
Can you help me?
Thank you in advance,
Cele
Posted by: Richard Phillips
Please see the attached notebook for functions that do what you want, for both precision and accuracy.
The code is pretty simple. It starts with random numbers of the target precision and just checks if the resulting output has the requested precision (or accuracy). If not it just tries again and again with increasing starting precision until it gets a sufficient output precision. Typically this is extremely efficient.
For almost all mathematical functions, say f, the precision of f[x] is different to the precision of x. This happens in my code, and I wasn't able to give a simple criterion for what the precision of the starting random numbers should be to give the required output precision. That's why it just tries repeatedly. Maybe someone could provide such a condition.
You might want to go and ask the same question to the Mathematica forum http://forums.wolfram.com/mathgroup/ also, since there are probably experts on numerical matters there.
Forum Sponsored by Wolfram Research
© 2004-2008 Wolfram Research, Inc. | Powered by vBulletin 2.3.0 © 2000-2002 Jelsoft Enterprises, Ltd. |
Disclaimer
vB Easy Archive Final - Created by Xenon and modified/released by SkuZZy from the Job Openings