Click or drag to resize
Accord.NET (logo)

VectorSample Method (Double, UInt16)

Returns a vector of the specified percentage of the populationSize containing non-repeating indices in the range [0, populationSize) in random order.

Namespace:  Accord.Math
Assembly:  Accord.Math (in Accord.Math.dll) Version: 3.8.0
Syntax
public static ushort[] Sample(
	double percentage,
	ushort populationSize
)
Request Example View Source

Parameters

percentage
Type: SystemDouble
The percentage of the population to sample.
populationSize
Type: SystemUInt16
The non-inclusive maximum number an index can have.

Return Value

Type: UInt16
Examples
var a = Vector.Sample(0.3, 10);  // a possible output is { 1, 7, 4 };
var b = Vector.Sample(1.0, 10); // a possible output is { 5, 4, 2, 0, 1, 3, 7, 9, 8, 6 };

foreach (var i in Vector.Sample(0.2, 6))
{
   // ...
}
See Also