22 |
* Sampling from a random number generator:: |
* Sampling from a random number generator:: |
23 |
* Auxiliary random number generator functions:: |
* Auxiliary random number generator functions:: |
24 |
* Random number environment variables:: |
* Random number environment variables:: |
25 |
* Saving and restoring random number generator state:: |
* Copying random number generator state:: |
26 |
|
* Reading and writing random number generator state:: |
27 |
* Random number generator algorithms:: |
* Random number generator algorithms:: |
28 |
* Unix random number generators:: |
* Unix random number generators:: |
29 |
* Numerical Recipes generators:: |
* Numerical Recipes generators:: |
330 |
first value = 2720986350 |
first value = 2720986350 |
331 |
@end example |
@end example |
332 |
|
|
333 |
@node Saving and restoring random number generator state |
@node Copying random number generator state |
334 |
@section Saving and restoring random number generator state |
@section Copying random number generator state |
335 |
|
|
336 |
The above methods ignore the random number `state' which changes from |
The above methods ignore the random number `state' which changes from |
337 |
call to call. It is often useful to be able to save and restore the |
call to call. It is often useful to be able to save and restore the |
349 |
exact copy of the generator @var{r}. |
exact copy of the generator @var{r}. |
350 |
@end deftypefn |
@end deftypefn |
351 |
|
|
352 |
@deftypefn Random void gsl_rng_print_state (const gsl_rng * @var{r}) |
@node Reading and writing random number generator state |
353 |
This function prints a hex-dump of the state of the generator @var{r} to |
@section Reading and writing random number generator state |
354 |
@code{stdout}. At the moment its only use is for debugging. |
|
355 |
@end deftypefn |
The library provides functions for reading and writing the random |
356 |
|
number state to a file as binary data or formatted text. |
357 |
|
|
358 |
|
@deftypefun int gsl_rng_fwrite (FILE * @var{stream}, const gsl_rng * @var{r}) |
359 |
|
This function writes the random number state of the random number |
360 |
|
generator @var{r} to the stream @var{stream} in binary format. The |
361 |
|
return value is 0 for success and @code{GSL_EFAILED} if there was a |
362 |
|
problem writing to the file. Since the data is written in the native |
363 |
|
binary format it may not be portable between different architectures. |
364 |
|
@end deftypefun |
365 |
|
|
366 |
|
@deftypefun int gsl_rng_fread (FILE * @var{stream}, gsl_rng * @var{r}) |
367 |
|
This function reads the random number state into the random number |
368 |
|
generator @var{r} from the open stream @var{stream} in binary format. |
369 |
|
The random number generator @var{r} must be preinitialized with the |
370 |
|
correct random number generator type since type information is not |
371 |
|
saved. The return value is 0 for success and @code{GSL_EFAILED} if |
372 |
|
there was a problem reading from the file. The data is assumed to |
373 |
|
have been written in the native binary format on the same |
374 |
|
architecture. |
375 |
|
@end deftypefun |
376 |
|
|
377 |
|
@deftypefun int gsl_rng_fprintf (FILE * @var{stream}, const gsl_rng * @var{r}, const char * @var{sep}) |
378 |
|
This function writes the random number state of the random number |
379 |
|
generator @var{r} to the stream @var{stream} as hexadecimal bytes |
380 |
|
separated by the separator @var{sep}. This should contain only |
381 |
|
whitespace characters. The function returns 0 for success and |
382 |
|
@code{GSL_EFAILED} if there was a problem writing to the file. |
383 |
|
|
384 |
|
@noindent |
385 |
|
Using a separator @var{sep} that contains only a single space @code{ } will |
386 |
|
output the random number state on a single line, although this may |
387 |
|
become quite long depending on the generator type. Using the |
388 |
|
linebreak character @code{\n}, however, will output a single byte on |
389 |
|
each line. |
390 |
|
@end deftypefun |
391 |
|
|
392 |
|
@deftypefun int gsl_rng_fscanf (FILE * @var{stream}, gsl_rng * @var{r}) |
393 |
|
This function reads the random number state from the stream |
394 |
|
@var{stream} into the random number generator @var{r}. The data is |
395 |
|
assumed to be in the format used by @code{gsl_rng_fprintf}, |
396 |
|
i.e. hexadecimal bytes separated by whitespace characters. The random |
397 |
|
number generator @var{r} must be preinitialized with the correct |
398 |
|
random number generator type since type information is not saved. The |
399 |
|
function returns 0 for success and @code{GSL_EFAILED} if there was a |
400 |
|
problem reading from the file. |
401 |
|
@end deftypefun |
402 |
|
|
403 |
@node Random number generator algorithms |
@node Random number generator algorithms |
404 |
@section Random number generator algorithms |
@section Random number generator algorithms |