Some extension methods for Random for creating a few more kinds of random stuff.
RandomExtensions
00 Remarks
Imports from https://github.com/rvs76/superbest-random.git
01 Syntax
02 Methods
| Name | Overloads | Summary |
|---|---|---|
| Next | 1 | Returns a non-negative random integer that is less than the specified maximum. |
| NextNumber | 1 | Returns a non-negative random Int32. |
| Seed | 1 | A number used to calculate a starting value for the pseudo-random number sequence. |
| SetSeed | 1 | re-initialize of the random RandomExtensions.seeds object |
| randf | 1 | 返回min到max区间之内的一个和实数 |
| NextDouble | 4 | Returns a random floating-point number that is greater than or equal to 0.0, and less than 1.0. |
| NextInteger | 2 | Returns a random integer that is within a specified range. |
| GetNextBetween | 2 | |
| GetRandomValue | 1 | Returns a random floating-point number that is greater than or equal to min of the range, and less than the max of the range. |
| ExponentialRandomNumbers | 1 | np.random.exponential |
| NextGaussian | 2 | |
| NextTriangular | 1 | Generates values from a triangular distribution. |
| NextBoolean | 2 | |
| Shuffle | 4 | makes the element inside the input list random orders |
| Shuffle | 3 | |
| Permutation | 1 | Returns n unique random numbers in the range [1, n], inclusive. |
| RandomSingle | 1 | |
| GetBytes | 1 | |
| GetNextNormalNumber | 1 |
03 Properties
| Name | Overloads | Summary |
|---|---|---|
| seeds | 1 | 一般来说,在获取随机数的时候并不推荐重新构建一个新的随机数发生器 可以在全局范围内重复使用这个随机数发生器 不同的代码重复使用这个种子,这样子可以尽量的模拟出真正的随机行为 |
04 Fields
| Name | Overloads | Summary |
|---|---|---|
| _seeds | 1 | make a new random generator for all thread |
05 Members
Int32)Returns a non-negative random integer that is less than the specified maximum.
| Name | Type | Description |
|---|---|---|
upbound | Int32 | The exclusive upper bound of the random number to be generated. maxValue must be greater than or equal to 0. |
A 32-bit signed integer that is greater than or equal to 0, and less than maxValue; that is, the range of return values ordinarily includes 0 but not maxValue. However, if maxValue equals 0, maxValue is returned.
Returns a non-negative random Int32.
Random.Next()
A 32-bit signed integer that is greater than or equal to 0 and less than Int32.MaxValue.
A number used to calculate a starting value for the pseudo-random number sequence. If a negative number is specified, the absolute value of the number is used.
Int32)re-initialize of the random RandomExtensions.seeds object
| Name | Type | Description |
|---|---|---|
seed | Int32 | - |
Double, Double)返回min到max区间之内的一个和实数
| Name | Type | Description |
|---|---|---|
min | Double | - |
max | Double | - |
Returns a random floating-point number that is greater than or equal to 0.0, and less than 1.0.
Random.NextDouble(), GetNextUniformNumber()
A double-precision floating point number that is greater than or equal to 0.0, and less than 1.0.
Double, Double)Returns a random floating-point number that is greater than or equal to min of the range, and less than the max of the range.
Random, DoubleRange)Returns a random floating-point number that is greater than or equal to min of the range, and less than the max of the range.
| Name | Type | Description |
|---|---|---|
rnd | Random | - |
range | DoubleRange | - |
Int32)Returns a non-negative random integer that is less than the specified maximum.
| Name | Type | Description |
|---|---|---|
upper | Int32 | The exclusive upper bound of the random number to be generated. maxValue must be greater than or equal to 0. |
A 32-bit signed integer that is greater than or equal to 0, and less than maxValue; that is, the range of return values ordinarily includes 0 but not maxValue. However, if maxValue equals 0, maxValue is returned.
Int32, Int32)Returns a random integer that is within a specified range.
| Name | Type | Description |
|---|---|---|
min | Int32 | The inclusive lower bound of the random number returned. |
max | Int32 | The exclusive upper bound of the random number returned. maxValue must be greater than or equal to minValue. |
A 32-bit signed integer greater than or equal to minValue and less than maxValue; that is, the range of return values includes minValue but not maxValue. If minValue equals maxValue, minValue is returned.
Random, Double, Double)Returns a random floating-point number that is greater than or equal to min of the range, and less than the max of the range.
| Name | Type | Description |
|---|---|---|
r | Random | - |
min# | Double | - |
max# | Double | - |
Returns a random floating-point number that is greater than or equal to min of the range, and less than the max of the range.
| Name | Type | Description |
|---|---|---|
rng | DoubleRange | - |
Double, Int32)np.random.exponential
| Name | Type | Description |
|---|---|---|
lambda | Double | - |
size | Int32 | - |
Random, Double, Double)Generates normally distributed numbers. Each operation makes two Gaussians for the price of one, and apparently they can be cached or something for better performance, but who cares.
| Name | Type | Description |
|---|---|---|
r | Random | - |
mu | Double | Mean of the distribution |
sigma | Double | Standard deviation |
Random, Double, Double, Double)Generates values from a triangular distribution.
See http://en.wikipedia.org/wiki/Triangular_distribution for a description of the triangular probability distribution and the algorithm for generating one.
| Name | Type | Description |
|---|---|---|
r | Random | - |
a | Double | Minimum |
b | Double | Maximum |
c | Double | Mode (most frequent value) |
Random)Equally likely to return true or false. Uses Random.Next().
1 > 0 OR 0 > 0Random, List(Of ``0))Shuffles a list in O(n) time by using the Fisher-Yates/Knuth algorithm.
| Name | Type | Description |
|---|---|---|
r | Random | - |
list | List(Of ``0) | - |
Random, ``0(), Nullable(Of Int32))Shuffles a list in O(n) time by using the Fisher-Yates/Knuth algorithm.
| Name | Type | Description |
|---|---|---|
r | Random | - |
list | ``0() | - |
makes the element inside the input list random orders
| Name | Description |
|---|---|
T |
| Name | Type | Description |
|---|---|---|
list | List(Of ``0) | - |
``0())makes the element inside the input list random orders
| Name | Description |
|---|---|
T |
| Name | Type | Description |
|---|---|---|
list | ``0() | - |
Random, IList)Shuffles a list in O(n) time by using the Fisher-Yates/Knuth algorithm.
| Name | Type | Description |
|---|---|---|
r | Random | - |
list | IList | - |
Random, Int32, Int32)Returns n unique random numbers in the range [1, n], inclusive. This is equivalent to getting the first n numbers of some random permutation of the sequential numbers from 1 to max.
Runs in O(k^2) time.
| Name | Type | Description |
|---|---|---|
rand | Random | - |
n | Int32 | Maximum number possible.(最大值) |
k | Int32 | How many numbers to return.(返回的数据的数目) |
一般来说,在获取随机数的时候并不推荐重新构建一个新的随机数发生器 可以在全局范围内重复使用这个随机数发生器 不同的代码重复使用这个种子,这样子可以尽量的模拟出真正的随机行为
the random seed value of this property value can be reset by the RandomExtensions.SetSeed() method.
A thread safe random value generator. No needs for synclock
make a new random generator for all thread
Int32)Random, Double, Double)Double, Double)Random, T(), Nullable(Of Int32))