nuget server logo nuget api documents
↑

API Docs / Microsoft.VisualBasic.Runtime / RandomExtensions

RandomExtensions

Full name Microsoft.VisualBasic.Math.RandomExtensions Assembly Microsoft.VisualBasic.Runtime Members 33

Some extension methods for Random for creating a few more kinds of random stuff.

00 Remarks

Imports from https://github.com/rvs76/superbest-random.git

01 Syntax

Microsoft.VisualBasic.Math.RandomExtensions

02 Methods

NameOverloadsSummary
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

NameOverloadsSummary
seeds 1 一般来说,在获取随机数的时候并不推荐重新构建一个新的随机数发生器 可以在全局范围内重复使用这个随机数发生器 不同的代码重复使用这个种子,这样子可以尽量的模拟出真正的随机行为

04 Fields

NameOverloadsSummary
_seeds 1 make a new random generator for all thread

05 Members

method Next #
Next(Int32)

Returns a non-negative random integer that is less than the specified maximum.

Parameters
NameTypeDescription
upboundInt32

The exclusive upper bound of the random number to be generated. maxValue must be greater than or equal to 0.

Returns

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.

method NextNumber #
NextNumber

Returns a non-negative random Int32.

Remarks

Random.Next()

Returns

A 32-bit signed integer that is greater than or equal to 0 and less than Int32.MaxValue.

method Seed #
Seed

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.

method SetSeed #
SetSeed(Int32)

re-initialize of the random RandomExtensions.seeds object

Parameters
NameTypeDescription
seedInt32

-

method randf #
randf(Double, Double)

返回min到max区间之内的一个和实数

Parameters
NameTypeDescription
minDouble

-

maxDouble

-

method NextDouble #
NextDouble

Returns a random floating-point number that is greater than or equal to 0.0, and less than 1.0.

Remarks

Random.NextDouble(), GetNextUniformNumber()

Returns

A double-precision floating point number that is greater than or equal to 0.0, and less than 1.0.

method NextDouble overload 2 #
NextDouble(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.

method NextDouble overload 3 #
NextDouble(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.

Parameters
NameTypeDescription
rndRandom

-

rangeDoubleRange

-

method NextInteger overload 2 #
NextInteger(Int32)

Returns a non-negative random integer that is less than the specified maximum.

Parameters
NameTypeDescription
upperInt32

The exclusive upper bound of the random number to be generated. maxValue must be greater than or equal to 0.

Returns

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.

method NextInteger #
NextInteger(Int32, Int32)

Returns a random integer that is within a specified range.

Parameters
NameTypeDescription
minInt32

The inclusive lower bound of the random number returned.

maxInt32

The exclusive upper bound of the random number returned. maxValue must be greater than or equal to minValue.

Returns

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.

method GetNextBetween overload 2 #
GetNextBetween(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.

Parameters
NameTypeDescription
rRandom

-

min#Double

-

max#Double

-

method GetRandomValue #
GetRandomValue(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.

Parameters
NameTypeDescription
rngDoubleRange

-

method ExponentialRandomNumbers #
ExponentialRandomNumbers(Double, Int32)

np.random.exponential

Parameters
NameTypeDescription
lambdaDouble

-

sizeInt32

-

method NextGaussian overload 2 #
NextGaussian(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.

Parameters
NameTypeDescription
rRandom

-

muDouble

Mean of the distribution

sigmaDouble

Standard deviation

method NextTriangular #
NextTriangular(Random, Double, Double, Double)

Generates values from a triangular distribution.

Remarks

See http://en.wikipedia.org/wiki/Triangular_distribution for a description of the triangular probability distribution and the algorithm for generating one.

Parameters
NameTypeDescription
rRandom

-

aDouble

Minimum

bDouble

Maximum

cDouble

Mode (most frequent value)

method NextBoolean overload 2 #
NextBoolean(Random)

Equally likely to return true or false. Uses Random.Next().

Remarks
 1 > 0 OR 0 > 0
method Shuffle overload 4 #
Shuffle``1(Random, List(Of ``0))

Shuffles a list in O(n) time by using the Fisher-Yates/Knuth algorithm.

Parameters
NameTypeDescription
rRandom

-

listList(Of ``0)

-

method Shuffle overload 3 #
Shuffle``1(Random, ``0(), Nullable(Of Int32))

Shuffles a list in O(n) time by using the Fisher-Yates/Knuth algorithm.

Parameters
NameTypeDescription
rRandom

-

list``0()

-

method Shuffle overload 2 #
Shuffle``1(List(Of ``0))

makes the element inside the input list random orders

Type Parameters
NameDescription
T
Parameters
NameTypeDescription
listList(Of ``0)

-

method Shuffle #
Shuffle``1(``0())

makes the element inside the input list random orders

Type Parameters
NameDescription
T
Parameters
NameTypeDescription
list``0()

-

method Shuffle overload 2 #
Shuffle(Random, IList)

Shuffles a list in O(n) time by using the Fisher-Yates/Knuth algorithm.

Parameters
NameTypeDescription
rRandom

-

listIList

-

method Permutation #
Permutation(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.

Parameters
NameTypeDescription
randRandom

-

nInt32

Maximum number possible.(最大值)

kInt32

How many numbers to return.(返回的数据的数目)

property seeds #
seeds

一般来说,在获取随机数的时候并不推荐重新构建一个新的随机数发生器 可以在全局范围内重复使用这个随机数发生器 不同的代码重复使用这个种子,这样子可以尽量的模拟出真正的随机行为

Remarks

the random seed value of this property value can be reset by the RandomExtensions.SetSeed() method.

Returns

A thread safe random value generator. No needs for synclock

field _seeds #
_seeds

make a new random generator for all thread

method RandomSingle #
RandomSingle()
method GetBytes #
GetBytes(Int32)
method GetNextBetween #
GetNextBetween(IntRange)
method NextDouble overload 4 #
NextDouble(Random, Double, Double)
method GetNextNormalNumber #
GetNextNormalNumber()
method NextGaussian #
NextGaussian(Double, Double)
method NextBoolean #
NextBoolean()
method Shuffle overload 3 #
Shuffle(Random, T(), Nullable(Of Int32))
method Shuffle #
Shuffle(List(Of T))