本文整理汇总了C#中IContinuousDistribution.Sample方法的典型用法代码示例。如果您正苦于以下问题:C# IContinuousDistribution.Sample方法的具体用法?C# IContinuousDistribution.Sample怎么用?C# IContinuousDistribution.Sample使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IContinuousDistribution
的用法示例。
在下文中一共展示了IContinuousDistribution.Sample方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create2DimTeachingVectors
public static List<PatternClass> Create2DimTeachingVectors(double p1, double p2, IContinuousDistribution generatorFirstFeature1, IContinuousDistribution generatorFirstFeature2, IContinuousDistribution generatorSecondFeature1, IContinuousDistribution generatorSecondFeature2, int nrOfTeachingVectors)
{
List<PatternClass> createdTeachingVectors = new List<PatternClass>();
if (probabilityGenerator == null)
{
probabilityGenerator = new ContinuousUniform(0, 1);
probabilityGenerator.RandomSource = new Random(DateTime.Now.Millisecond + 10);
}
for (int i = 0; i < nrOfTeachingVectors; i++)
{
double value = 0;
double value1 = 0;
int classNumber = CreateClass(p1, p2);
if (classNumber == 1)
{
value = generatorFirstFeature1.Sample();
value1 = generatorSecondFeature1.Sample();
}
else if (classNumber == 2)
{
value = generatorFirstFeature2.Sample();
value1 = generatorSecondFeature2.Sample();
}
createdTeachingVectors.Add(new PatternClass(new FeatureVector(value,value1), classNumber));
}
return createdTeachingVectors;
}
示例2: Create2dimSampleObject
public static List<PatternClass> Create2dimSampleObject(IContinuousDistribution generator, IContinuousDistribution generator1, int count, int classNumber)
{
List<PatternClass> sampleObjects = new List<PatternClass>();
probabilityGenerator = new ContinuousUniform(0, 1);
probabilityGenerator.RandomSource = new Random(DateTime.Now.Millisecond + 10);
for (int i = 0; i < count; i++)
{
sampleObjects.Add(new PatternClass(new FeatureVector(generator.Sample(), generator1.Sample()), classNumber));
}
return sampleObjects;
}
示例3: CreateRandom
/// <summary>
/// Create a new dense vector with values sampled from the provided random distribution.
/// </summary>
public static DenseVector CreateRandom(int size, IContinuousDistribution distribution)
{
var storage = new DenseVectorStorage<Complex>(size);
for (var i = 0; i < storage.Data.Length; i++)
{
storage.Data[i] = new Complex(distribution.Sample(), distribution.Sample());
}
return new DenseVector(storage);
}
示例4: CreateRandom
/// <summary>
/// Create a new diagonal matrix with diagonal values sampled from the provided random distribution.
/// </summary>
public static DiagonalMatrix CreateRandom(int rows, int columns, IContinuousDistribution distribution)
{
return new DiagonalMatrix(DiagonalMatrixStorage<Complex>.OfInit(rows, columns,
i => new Complex(distribution.Sample(), distribution.Sample())));
}
示例5: CreateRandom
/// <summary>
/// Create a new dense matrix with values sampled from the provided random distribution.
/// </summary>
public static DenseMatrix CreateRandom(int rows, int columns, IContinuousDistribution distribution)
{
return new DenseMatrix(DenseColumnMajorMatrixStorage<float>.OfInit(rows, columns, (i, j) => (float) distribution.Sample()));
}
示例6: CreateRandom
/// <summary>
/// Create a new dense vector with values sampled from the provided random distribution.
/// </summary>
public static DenseVector CreateRandom(int length, IContinuousDistribution distribution)
{
return new DenseVector(DenseVectorStorage<Complex32>.OfInit(length,
i => new Complex32((float)distribution.Sample(), (float)distribution.Sample())));
}
示例7: CreateRandom
/// <summary>
/// Create a new dense vector with values sampled from the provided random distribution.
/// </summary>
public static DenseVector CreateRandom(int length, IContinuousDistribution distribution)
{
return new DenseVector(DenseVectorStorage<double>.OfInit(length,
i => distribution.Sample()));
}
示例8: CreateRandom
/// <summary>
/// Create a new dense matrix with values sampled from the provided random distribution.
/// </summary>
public static DenseMatrix CreateRandom(int rows, int columns, IContinuousDistribution distribution)
{
var storage = new DenseColumnMajorMatrixStorage<Complex>(rows, columns);
for (var i = 0; i < storage.Data.Length; i++)
{
storage.Data[i] = new Complex(distribution.Sample(), distribution.Sample());
}
return new DenseMatrix(storage);
}
示例9: Random
/// <summary>
/// Generates a vector with random elements
/// </summary>
/// <param name="length">Number of elements in the vector.</param>
/// <param name="randomDistribution">Continuous Random Distribution or Source</param>
/// <returns>
/// A vector with n-random elements distributed according
/// to the specified random distribution.
/// </returns>
/// <exception cref="ArgumentNullException">If the length vector is non poisitive<see langword="null" />.</exception>
public override Vector Random(int length, IContinuousDistribution randomDistribution)
{
if (length < 0)
{
throw new ArgumentException(Resources.ArgumentMustBePositive, "length");
}
var v = (SparseVector)this.CreateVector(length);
for (var index = 0; index < v.Count; index++)
{
v[index] = randomDistribution.Sample();
}
return v;
}
示例10: Random
/// <summary>
/// Generates matrix with random elements.
/// </summary>
/// <param name="numberOfRows">Number of rows.</param>
/// <param name="numberOfColumns">Number of columns.</param>
/// <param name="distribution">Continuous Random Distribution or Source</param>
/// <returns>
/// An <c>numberOfRows</c>-by-<c>numberOfColumns</c> matrix with elements distributed according to the provided distribution.
/// </returns>
/// <exception cref="ArgumentException">If the parameter <paramref name="numberOfRows"/> is not positive.</exception>
/// <exception cref="ArgumentException">If the parameter <paramref name="numberOfColumns"/> is not positive.</exception>
public virtual Matrix Random(int numberOfRows, int numberOfColumns, IContinuousDistribution distribution)
{
if (numberOfRows < 1)
{
throw new ArgumentException(Resources.ArgumentMustBePositive, "numberOfRows");
}
if (numberOfColumns < 1)
{
throw new ArgumentException(Resources.ArgumentMustBePositive, "numberOfColumns");
}
var matrix = CreateMatrix(numberOfRows, numberOfColumns);
CommonParallel.For(
0,
ColumnCount,
j =>
{
for (var i = 0; i < matrix.RowCount; i++)
{
matrix[i, j] = distribution.Sample();
}
});
return matrix;
}
示例11: Random
/// <summary>
/// Generates a vector with random elements
/// </summary>
/// <param name="length">Number of elements in the vector.</param>
/// <param name="randomDistribution">Continuous Random Distribution or Source</param>
/// <returns>
/// A vector with n-random elements distributed according
/// to the specified random distribution.
/// </returns>
/// <exception cref="ArgumentNullException">If the n vector is non positive<see langword="null" />.</exception>
public override Vector<Complex32> Random(int length, IContinuousDistribution randomDistribution)
{
if (length < 1)
{
throw new ArgumentException(Resources.ArgumentMustBePositive, "length");
}
var v = (DenseVector)CreateVector(length);
for (var index = 0; index < v.Data.Length; index++)
{
v.Data[index] = new Complex32((float)randomDistribution.Sample(), (float)randomDistribution.Sample());
}
return v;
}
示例12: Random
/// <summary>
/// Generates matrix with random elements.
/// </summary>
/// <param name="numberOfRows">Number of rows.</param>
/// <param name="numberOfColumns">Number of columns.</param>
/// <param name="distribution">Continuous Random Distribution or Source</param>
/// <returns>
/// An <c>numberOfRows</c>-by-<c>numberOfColumns</c> matrix with elements distributed according to the provided distribution.
/// </returns>
/// <exception cref="ArgumentException">If the parameter <paramref name="numberOfRows"/> is not positive.</exception>
/// <exception cref="ArgumentException">If the parameter <paramref name="numberOfColumns"/> is not positive.</exception>
public override Matrix Random(int numberOfRows, int numberOfColumns, IContinuousDistribution distribution)
{
if (numberOfRows < 1)
{
throw new ArgumentException(Resources.ArgumentMustBePositive, "numberOfRows");
}
if (numberOfColumns < 1)
{
throw new ArgumentException(Resources.ArgumentMustBePositive, "numberOfColumns");
}
var matrix = (SparseMatrix)CreateMatrix(numberOfRows, numberOfColumns);
for (var i = 0; i < matrix.RowCount; i++)
{
for (var j = 0; j < matrix.ColumnCount; j++)
{
var value = distribution.Sample();
if (value != 0.0)
{
matrix.SetValueAt(i, j, value);
}
}
}
return matrix;
}