1RNG(3)                User Contributed Perl Documentation               RNG(3)
2
3
4

NAME

6       PDL::GSL::RNG - PDL interface to RNG and randist routines in GSL
7

DESCRIPTION

9       This is an interface to the rng and randist packages present in the GNU
10       Scientific Library.
11

SYNOPSIS

13          use PDL;
14          use PDL::GSL::RNG;
15
16          $rng = PDL::GSL::RNG->new('taus');
17
18          $rng->set_seed(time());
19
20          $a=zeroes(5,5,5)
21
22          $rng->get_uniform($a); # inplace
23
24          $b=$rng->get_uniform(3,4,5); # creates new pdl
25

FUNCTIONS

27       new()
28
29       The new method initializes a new instance of the RNG.
30
31       The avaible RNGs are: slatec, cmrg, gfsr4, minstd, mrg, mt19937, r250,
32       ran0, ran1, ran2, ran3, rand48, rand, random8_bsd, random8_glibc2, ran‐
33       dom8_libc5, random128_bsd, random128_glibc2, random128_libc5, ran‐
34       dom256_bsd, random256_glibc2, random256_libc5, random32_bsd, ran‐
35       dom32_glibc2, random32_libc5, random64_bsd, random64_glibc2, ran‐
36       dom64_libc5, random_bsd, random_glibc2, random_libc5, randu, ranf, ran‐
37       lux389, ranlux, ranmar, taus, transputer, tt800, uni32, uni, vax, zuf,
38       default. The last one (default) uses the enviroment variable
39       GSL_RNG_TYPE. Please check the GSL documentation for more information.
40
41       Usage:
42
43          $blessed_ref = PDL::GSL::RNG->new($RNG_name);
44
45       Example:
46
47          $rng = PDL::GSL::RNG->new('taus');
48
49       set_seed();
50
51       Sets the RNG seed.
52
53       Usage:
54
55          $rng->set_seed($integer);
56
57       Example:
58
59          $rng->set_seed(666);
60
61       min()
62
63       Return the minimum value generable by this RNG.
64
65       Usage:
66
67          $integer = $rng->min();
68
69       Example:
70
71          $min = $rng->min(); $max = $rng->max();
72
73       max()
74
75       Return the maximum value generable by the RNG.
76
77       Usage:
78
79          $integer = $rng->max();
80
81       Example:
82
83          $min = $rng->min(); $max = $rng->max();
84
85       name()
86
87       Returns the name of the RNG.
88
89       Usage:
90
91          $string = $rng->name();
92
93       Example:
94
95          $name = $rng->name();
96
97       get_uniform()
98
99       This function creates a piddle with given dimensions or accept an
100       existing piddle and fills it. get_uniform() returns values 0<=x<1,
101
102       Usage:
103
104          $piddle = $rng->get_uniform($list_of_integers)
105          $rng->get_uniform($piddle);
106
107       Example:
108
109          $a = zeroes 5,6; $max=100;
110          $o = $rng->get_uniform(10,10); $rng->get_uniform($a);
111
112       get_uniform_pos()
113
114       This function creates a piddle with given dimensions or accept an
115       existing piddle and fills it. get_uniform_pos() returns values 0<x<1,
116
117       Usage:
118
119          $piddle = $rng->get_uniform_pos($list_of_integers)
120          $rng->get_uniform_pos($piddle);
121
122       Example:
123
124          $a = zeroes 5,6;
125          $o = $rng->get_uniform_pos(10,10); $rng->get_uniform_pos($a);
126
127       get()
128
129       This function creates a piddle with given dimensions or accept an
130       existing piddle and fills it. get() returns integer values beetween a
131       minimum and a maximum specific to evry RNG.
132
133       Usage:
134
135          $piddle = $rng->get($list_of_integers)
136          $rng->get($piddle);
137
138       Example:
139
140          $a = zeroes 5,6;
141          $o = $rng->get(10,10); $rng->get($a);
142
143       get_int()
144
145       This function creates a piddle with given dimensions or accept an
146       existing piddle and fills it. get_int() returns integer values beetween
147       0 and $max.
148
149       Usage:
150
151          $piddle = $rng->get($max, $list_of_integers)
152          $rng->get($max, $piddle);
153
154       Example:
155
156          $a = zeroes 5,6; $max=100;
157          $o = $rng->get(10,10); $rng->get($a);
158
159       ran_gaussian()
160
161       These functions return random deviates from given distribution.
162
163       The general form is
164
165         ran_[distrib](args)
166
167       where distrib can be any of the ones shown below.
168
169       They accept the parameters of the distribution and a specification of
170       where to put output. This spec can be in form of list of integers that
171       specify the dimensions of the ouput piddle or an existing piddle that
172       will be filled with values inplace.
173
174       Usage:
175
176          # gaussian dist
177          $piddle = $rng->ran_gaussian($sigma,[list of integers]);
178          $rng->ran_gaussian($sigma,$piddle);
179
180          # gaussian tail
181          $piddle = $rng->ran_ugaussian_tail($tail,[list of integers]);
182          $rng->ran_ugaussian_tail($tail,$piddle);
183
184          # exponential dist
185          $piddle = $rng->ran_exponential($mu,[list of integers]);
186          $rng->ran_exponential($mu,$piddle);
187
188          # laplacian dist
189          $piddle = $rng->ran_laplace($mu,[list of integers]);
190          $rng->ran_laplace($mu,$piddle);
191
192          $piddle = $rng->ran_exppow($mu,$a,[list of integers]);
193          $rng->ran_exppow($mu,$a,$piddle);
194
195          $piddle = $rng->ran_cauchy($mu,[list of integers]);
196          $rng->ran_cauchy($mu,$piddle);
197
198          $piddle = $rng->ran_rayleigh($sigma,[list of integers]);
199          $rng->ran_rayleigh($sigma,$piddle);
200
201          $piddle = $rng->ran_rayleigh_tail($a,$sigma,[list of integers]);
202          $rng->ran_rayleigh_tail($a,$sigma,$piddle);
203
204          $piddle = $rng->ran_levy($mu,$a,[list of integers]);
205          $rng->ran_levy($mu,$a,$piddle);
206
207          $piddle = $rng->ran_gamma($a,$b,[list of integers]);
208          $rng->ran_gamma($a,$b,$piddle);
209
210          $piddle = $rng->ran_flat($a,$b,[list of integers]);
211          $rng->ran_flat($a,$b,$piddle);
212
213          $piddle = $rng->ran_lognormal($zeta, $sigma,[list of integers]);
214          $rng->ran_lognormal($zeta, $sigma,$piddle);
215
216          $piddle = $rng->ran_chisq($nu,[list of integers]);
217          $rng->ran_chisq($nu,$piddle);
218
219          $piddle = $rng->ran_fdist($nu1, $nu2,[list of integers]);
220          $rng->ran_fdist($nu1, $nu2,$piddle);
221
222          $piddle = $rng->ran_tdist($nu,[list of integers]);
223          $rng->ran_tdist($nu,$piddle);
224
225          $piddle = $rng->ran_beta($a,$b,[list of integers]);
226          $rng->ran_beta($a,$b,$piddle);
227
228          $piddle = $rng->ran_logistic($m,[list of integers]u)
229          $rng->ran_logistic($m,$piddleu)
230
231          $piddle = $rng->ran_pareto($a,$b,[list of integers]);
232          $rng->ran_pareto($a,$b,$piddle);
233
234          $piddle = $rng->ran_weibull($mu,$a,[list of integers]);
235          $rng->ran_weibull($mu,$a,$piddle);
236
237          $piddle = $rng->ran_gumbel1($a,$b,[list of integers]);
238          $rng->ran_gumbel1($a,$b,$piddle);
239
240          $piddle = $rng->ran_gumbel2($a,$b,[list of integers]);
241          $rng->ran_gumbel2($a,$b,$piddle);
242
243          $piddle = $rng->ran_poisson($mu,[list of integers]);
244          $rng->ran_poisson($mu,$piddle);
245
246          $piddle = $rng->ran_bernoulli($p,[list of integers]);
247          $rng->ran_bernoulli($p,$piddle);
248
249          $piddle = $rng->ran_binomial($p,$n,[list of integers]);
250          $rng->ran_binomial($p,$n,$piddle);
251
252          $piddle = $rng->ran_negative_binomial($p,$n,[list of integers]);
253          $rng->ran_negative_binomial($p,$n,$piddle);
254
255          $piddle = $rng->ran_pascal($p,$n,[list of integers]);
256          $rng->ran_pascal($p,$n,$piddle);
257
258          $piddle = $rng->ran_geometric($p,[list of integers]);
259          $rng->ran_geometric($p,$piddle);
260
261          $piddle = $rng->ran_hypergeometric($n1, $n2, $t,[list of integers]);
262          $rng->ran_hypergeometric($n1, $n2, $t,$piddle);
263
264          $piddle = $rng->ran_logarithmic($p,[list of integers]);
265          $rng->ran_logarithmic($p,$piddle);
266
267       Example:
268
269         $o = $rng->ran_gaussian($sigma,10,10);
270         $rng->ran_gaussian($sigma,$a);
271
272       ran_gaussian_var()
273
274       This method is similar to ran_[distrib]() except that it takes the
275       parameters of the distribution as a piddle and returns a piddle of
276       equal dimensions. Of course, you can use the same set of distributions
277       as in the previous method (see also the ran_gaussian entry above).
278
279       Usage:
280
281          $piddle = $rng->ran_[distribution]_var($distr_parameters_list,$piddle_dim_list);
282          $rng->ran_[distribution]_var($distr_parameters_list,$piddle);
283
284       Example:
285
286          $sigma_pdl = rvals zeroes 11,11;
287          $o = $rng->ran_gaussian_var($sigma_pdl);
288
289       ran_additive_gaussian()
290
291       Add Gaussian noise of given sigma to a piddle.
292
293       Usage:
294
295          $rng->ran_additive_gaussian($sigma,$piddle);
296
297       Example:
298
299          $rng->ran_additive_gaussian(1,$image);
300
301       ran_additive_poisson()
302
303       Add Poisson noise of given sigma to a piddle.
304
305       Usage:
306
307          $rng->ran_additive_poisson($mu,$piddle);
308
309       Example:
310
311          $rng->ran_additive_poisson(1,$image);
312
313       ran_feed_poisson()
314
315       This method simulates shot noise, taking the values of piddle as values
316       for mu to be fed in the poissonian RNG.
317
318       Usage:
319
320          $rng->ran_feed_poisson($piddle);
321
322       Example:
323
324          $rng->ran_feed_poisson($image);
325
326       ran_bivariate_gaussian()
327
328       Generates $n bivariate gaussian random deviates.
329
330       Usage:
331
332          $piddle = $rng->ran_bivariate_gaussian($sigma_x,$sigma_y,$rho,$n);
333
334       Example:
335
336          $o = $rng->ran_bivariate_gaussian(1,2,0.5,1000);
337
338       ran_dir()
339
340       Returns $n random vectors in $ndim dimensions.
341
342       Usage:
343
344          $piddle = $rng->ran_dir($ndim,$n);
345
346       Example:
347
348          $o = $rng->ran_dir($ndim,$n);
349
350       ran_discrete_preproc()
351
352       This method returns a handle that must be used when calling ran_dis‐
353       crete(). You specify the probability of the integer number that are
354       returned by ran_discrete().
355
356       Usage:
357
358          $discrete_dist_handle = $rng->ran_discrete_preproc($double_piddle_prob);
359
360       Example:
361
362          $prob = pdl [0.1,0.3,0.6];
363          $ddh = $rng->ran_discrete_preproc($prob);
364          $o = $rng->ran_discrete($discrete_dist_handle,100);
365
366       ran_discrete()
367
368       Is used to get the desired samples once a proper handle has been ensta‐
369       blished (see ran_discrete_preproc()).
370
371       Usage:
372
373          $piddle = $rng->ran_discrete($discrete_dist_handle,$num);
374
375       Example:
376
377          $prob = pdl [0.1,0.3,0.6];
378          $ddh = $rng->ran_discrete_preproc($prob);
379          $o = $rng->ran_discrete($discrete_dist_handle,100);
380
381       ran_shuffle()
382
383       Shuffles values in piddle
384
385       Usage:
386
387          $rng->ran_shuffle($piddle);
388
389       ran_shuffle_vec()
390
391       Shuffles values in piddle
392
393       Usage:
394
395          $rng->ran_shuffle_vec(@vec);
396
397       ran_choose()
398
399       Chooses values from $inpiddle to $outpiddle.
400
401       Usage:
402
403          $rng->ran_choose($inpiddle,$outpiddle);
404
405       ran_choose_vec()
406
407       Chooses $n values from @vec.
408
409       Usage:
410
411          @choosen = $rng->ran_choose_vec($n,@vec);
412
413       ran_ver()
414
415       Returns a piddle with $n values generated by the Verhulst map from $x0
416       and paramater $r.
417
418       Usage:
419
420          $rng->ran_ver($x0, $r, $n);
421
422       ran_caos()
423
424       Returns values from Verhuls map with $r=4.0 and randomly choosen $x0.
425       The values are scaled by $m.
426
427       Usage:
428
429          $rng->ran_caos($m,$n);
430

BUGS

432       Feedback is welcome. Log bugs in the PDL bug database (the database is
433       always linked from <http://pdl.perl.org/>).
434

SEE ALSO

436       PDL
437
438       The GSL documentation is online at <http://www.gnu.org/soft
439       ware/gsl/manual/html_node/>
440

AUTHOR

442       This file copyright (C) 1999 Christian Pellegrin <chri@infis.univ.tri‐
443       este.it> Docs mangled by C. Soeller. All rights reserved. There is no
444       warranty. You are allowed to redistribute this software / documentation
445       under certain conditions. For details, see the file COPYING in the PDL
446       distribution. If this file is separated from the PDL distribution, the
447       copyright notice should be included in the file.
448
449       The GSL RNG and randist modules were written by James Theiler.
450
451
452
453perl v5.8.8                       2006-12-02                            RNG(3)
Impressum