You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Returns new Rand that uses random values from src to generate other random values\.
59
+
60
+
## I64
61
+
```jule
62
+
fn I64(): i64
63
+
```
64
+
Returns a non\-negative pseudo\-random 63\-bit integer as an i64 from the default Source\.
65
+
66
+
## U32
67
+
```jule
68
+
fn U32(): u32
69
+
```
70
+
Returns a pseudo\-random 32\-bit value as a u32 from the default Source\.
71
+
72
+
## U64N
73
+
```jule
74
+
fn U64N(n: u64): u64
75
+
```
76
+
Returns, as a u64, a pseudo\-random number in the half\-open interval \[0,n\) from the default Source\. It panics if n == 0\.
77
+
78
+
## U32N
79
+
```jule
80
+
fn U32N(n: u32): u32
81
+
```
82
+
Returns, as a u32, a pseudo\-random number in the half\-open interval \[0,n\) from the default Source\. It panics if n == 0\.
83
+
84
+
## U64
85
+
```jule
86
+
fn U64(): u64
87
+
```
88
+
Returns a pseudo\-random 64\-bit value as a u64 from the default Source\.
89
+
90
+
## I32
91
+
```jule
92
+
fn I32(): i32
93
+
```
94
+
Returns a non\-negative pseudo\-random 31\-bit integer as an i32 from the default Source\.
95
+
96
+
## Int
97
+
```jule
98
+
fn Int(): int
99
+
```
100
+
Returns a non\-negative pseudo\-random int from the default Source\.
101
+
102
+
## Uint
103
+
```jule
104
+
fn Uint(): uint
105
+
```
106
+
Returns a pseudo\-random uint from the default Source\.
107
+
108
+
## I64N
109
+
```jule
110
+
fn I64N(n: i64): i64
111
+
```
112
+
Returns, as an i64, a pseudo\-random number in the half\-open interval \[0,n\) from the default Source\. It panics if n <= 0\.
113
+
114
+
## Int32N
115
+
```jule
116
+
fn Int32N(n: i32): i32
117
+
```
118
+
Returns, as an i32, a pseudo\-random number in the half\-open interval \[0,n\) from the default Source\. It panics if n <= 0\.
119
+
120
+
## IntN
121
+
```jule
122
+
fn IntN(n: int): int
123
+
```
124
+
Returns, as an int, a pseudo\-random number in the half\-open interval \[0,n\) from the default Source\. It panics if n <= 0\.
125
+
126
+
## UintN
127
+
```jule
128
+
fn UintN(n: uint): uint
129
+
```
130
+
Returns, as a uint, a pseudo\-random number in the half\-open interval \[0,n\) from the default Source\. It panics if n == 0\.
131
+
132
+
## F64
133
+
```jule
134
+
fn F64(): f64
135
+
```
136
+
Returns, as a f64, a pseudo\-random number in the half\-open interval \[0\.0,1\.0\) from the default Source\.
137
+
138
+
## F32
139
+
```jule
140
+
fn F32(): f32
141
+
```
142
+
Returns, as a f32, a pseudo\-random number in the half\-open interval \[0\.0,1\.0\) from the default Source\.
143
+
144
+
## Perm
145
+
```jule
146
+
fn Perm(n: int): []int
147
+
```
148
+
Returns, as a slice of n ints, a pseudo\-random permutation of the integers in the half\-open interval \[0,n\) from the default Source\.
149
+
150
+
## Shuffle
151
+
```jule
152
+
fn Shuffle(n: int, swap: fn(i: int, j: int))
153
+
```
154
+
Shuffle pseudo\-randomizes the order of elements using the default Source\. n is the number of elements\. It panics if n < 0\. swap swaps the elements with indexes i and j\.
155
+
156
+
## NormF64
157
+
```jule
158
+
fn NormF64(): f64
159
+
```
160
+
Returns a normally distributed f64 in the range \[\-f64\.Max, \+f64\.Max\] with standard normal distribution \(mean = 0, stddev = 1\) from the default Source\. To produce a different normal distribution, callers can adjust the output using:
161
+
162
+
```
163
+
sample = NormF64() * desiredStdDev + desiredMean
164
+
```
165
+
166
+
167
+
## ExpFloat64
168
+
```jule
169
+
fn ExpFloat64(): f64
170
+
```
171
+
Returns an exponentially distributed f64 in the range \(0, \+f64\.Max\] with an exponential distribution whose rate parameter \(lambda\) is 1 and whose mean is 1/lambda \(1\) from the default Source\. To produce a distribution with a different rate parameter, callers can adjust the output using:
172
+
173
+
```
174
+
sample = ExpF64() / desiredRateParameter
28
175
```
29
-
Returns new default source by seed\.
30
176
31
-
The order and numbers produced vary depending on the seed\. Since PRNGs are inherently deterministic, using a fixed seed means your program will generate the same numbers every time\.
32
177
33
-
If you want to achieve randomness somehow, use a variable seed\. A simple solution for seeds that will create the illusion of randomness is to use time\. Unix\-time seconds would be a simple seed solution\.
Returns a Zipf variate generator\. The generator generates values k ∈ \[0, imax\] such that P\(k\) is proportional to \(v \+ k\)\*\*\(\-s\)\. Requirements: s > 1 and v >= 1\.
183
+
184
+
## NewPCG
185
+
```jule
186
+
fn NewPCG(seed1: u64, seed2: u64): &PCG
187
+
```
188
+
Returns a new PCG seeded with the given values\.
34
189
35
190
## Source
36
191
```jule
37
192
trait Source {
38
193
fn U64(*self): u64
39
194
}
40
195
```
41
-
Source of uniformly\-distributed pseudo\-random u64 values in the range \[0, 1<<64\)\. It is not safe for concurrent use by multiple threads\.
196
+
A Source is a source of uniformly\-distributed pseudo\-random u64 values in the range \[0, 1<<64\)\.
197
+
198
+
It is not safe for concurrent use by multiple threads\.
42
199
43
200
## Rand
44
201
```jule
@@ -48,11 +205,16 @@ struct Rand {
48
205
```
49
206
Implements a type of pseudo random number generator \(PRNG\)\. Outputs might be easily predictable regardless of how it's seeded\. For random numbers suitable for security\-sensitive work, it is not recommended\.
50
207
51
-
### New
208
+
### NormF64
52
209
```jule
53
-
fn New(src: Source): &Rand
210
+
fn NormF64(*self): f64
211
+
```
212
+
Returns a normally distributed f64 in the range \[\-f64\.Max, \+f64\.Max\] with standard normal distribution \(mean = 0, stddev = 1\) from the default Source\. To produce a different normal distribution, callers can adjust the output using:
213
+
214
+
```
215
+
sample = NormF64() * desiredStdDev + desiredMean
54
216
```
55
-
Returns new Rand that uses random values from src to generate other random values\.
217
+
56
218
57
219
### U64
58
220
```jule
@@ -84,39 +246,45 @@ fn Int(*self): int
84
246
```
85
247
Returns a non\-negative pseudo\-random int\.
86
248
87
-
### U64n
249
+
### Uint
250
+
```jule
251
+
fn Uint(*self): uint
252
+
```
253
+
Returns a pseudo\-random uint\.
254
+
255
+
### U64N
88
256
```jule
89
-
fn U64n(*self, n: u64): u64
257
+
fn U64N(*self, n: u64): u64
90
258
```
91
259
Returns, as a u64, a non\-negative pseudo\-random number in the half\-open interval \[0,n\)\. It panics if n == 0\.
92
260
93
-
### I64n
261
+
### I64N
94
262
```jule
95
-
fn I64n(*self, n: i64): i64
263
+
fn I64N(*self, n: i64): i64
96
264
```
97
265
Returns, as an i64, a non\-negative pseudo\-random number in the half\-open interval \[0,n\)\. It panics if n == 0\.
98
266
99
-
### I32n
267
+
### I32N
100
268
```jule
101
-
fn I32n(*self, n: i32): i32
269
+
fn I32N(*self, n: i32): i32
102
270
```
103
271
Returns, as an i32, a non\-negative pseudo\-random number in the half\-open interval \[0,n\)\. It panics if n <= 0\.
104
272
105
-
### U32n
273
+
### U32N
106
274
```jule
107
-
fn U32n(*self, n: u32): u32
275
+
fn U32N(*self, n: u32): u32
108
276
```
109
277
Returns, as a u32, a non\-negative pseudo\-random number in the half\-open interval \[0,n\)\. It panics if n == 0\.
110
278
111
-
### Intn
279
+
### IntN
112
280
```jule
113
-
fn Intn(*self, n: int): int
281
+
fn IntN(*self, n: int): int
114
282
```
115
283
Returns, as an int, a non\-negative pseudo\-random number in the half\-open interval \[0,n\)\. It panics if n <= 0\.
116
284
117
-
### Uintn
285
+
### UintN
118
286
```jule
119
-
fn Uintn(*self, n: uint): uint
287
+
fn UintN(*self, n: uint): uint
120
288
```
121
289
Returns, as a uint, a non\-negative pseudo\-random number in the half\-open interval \[0,n\)\. It panics if n == 0\.
122
290
@@ -130,4 +298,69 @@ Returns, as a f64, a pseudo\-random number in the half\-open interval \[0\.0,1\.
130
298
```jule
131
299
fn F32(*self): f32
132
300
```
133
-
Returns, as a f32, a pseudo\-random number in the half\-open interval \[0\.0,1\.0\)\.
301
+
Returns, as a f32, a pseudo\-random number in the half\-open interval \[0\.0,1\.0\)\.
302
+
303
+
### Perm
304
+
```jule
305
+
fn Perm(*self, n: int): []int
306
+
```
307
+
Returns, as a slice of n ints, a pseudo\-random permutation of the integers in the half\-open interval \[0,n\)\.
Shuffle pseudo\-randomizes the order of elements\. n is the number of elements\. It panics if n < 0\. swap swaps the elements with indexes i and j\.
314
+
315
+
### ExpF64
316
+
```jule
317
+
fn ExpF64(*self): f64
318
+
```
319
+
Returns an exponentially distributed f64 in the range \(0, \+f64\.Max\] with an exponential distribution whose rate parameter \(lambda\) is 1 and whose mean is 1/lambda \(1\) from the default Source\. To produce a distribution with a different rate parameter, callers can adjust the output using:
320
+
321
+
```
322
+
sample = ExpF64() / desiredRateParameter
323
+
```
324
+
325
+
326
+
## Zipf
327
+
```jule
328
+
struct Zipf {
329
+
// NOTE: contains filtered hidden or unexported fields
330
+
}
331
+
```
332
+
A Zipf generates Zipf distributed variates\.
333
+
334
+
### Implemented Traits
335
+
336
+
-`Source`
337
+
338
+
### U64
339
+
```jule
340
+
fn U64(*self): u64
341
+
```
342
+
Returns a value drawn from the Zipf distribution described by the Zipf object\.
343
+
344
+
## PCG
345
+
```jule
346
+
struct PCG {
347
+
// NOTE: contains filtered hidden or unexported fields
348
+
}
349
+
```
350
+
A PCG is a PCG generator with 128 bits of internal state\. A zero PCG is equivalent to NewPCG\(0, 0\)\.
351
+
352
+
### Implemented Traits
353
+
354
+
-`Source`
355
+
356
+
### Seed
357
+
```jule
358
+
fn Seed(*self, seed1: u64, seed2: u64)
359
+
```
360
+
Resets the PCG to behave the same way as NewPCG\(seed1, seed2\)\.
361
+
362
+
### U64
363
+
```jule
364
+
fn U64(*self): u64
365
+
```
366
+
Return a uniformly\-distributed random u64 value\.
0 commit comments