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

BUGS

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

SEE ALSO

412       PDL
413
414       The GSL documentation is online at
415       <http://www.gnu.org/software/gsl/manual/html_node/>
416

AUTHOR

418       This file copyright (C) 1999 Christian Pellegrin
419       <chri@infis.univ.trieste.it> Docs mangled by C. Soeller. All rights
420       reserved. There is no warranty. You are allowed to redistribute this
421       software / documentation under certain conditions. For details, see the
422       file COPYING in the PDL distribution. If this file is separated from
423       the PDL distribution, the copyright notice should be included in the
424       file.
425
426       The GSL RNG and randist modules were written by James Theiler.
427
428
429
430perl v5.12.3                      2011-03-31                            RNG(3)
Impressum