当前位置: 首页>>代码示例>>C#>>正文


C# IContinuousDistribution.Sample方法代码示例

本文整理汇总了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;
        }
开发者ID:michal-franc,项目名称:ImageClassification,代码行数:31,代码来源:Common.cs

示例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;
        }
开发者ID:michal-franc,项目名称:ImageClassification,代码行数:13,代码来源:Common.cs

示例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);
 }
开发者ID:cdrnet,项目名称:mathnet-numerics-native,代码行数:12,代码来源:DenseVector.cs

示例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())));
 }
开发者ID:smoothdeveloper,项目名称:mathnet-numerics,代码行数:8,代码来源:DiagonalMatrix.cs

示例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()));
 }
开发者ID:EraYaN,项目名称:EV2020,代码行数:7,代码来源:DenseMatrix.cs

示例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())));
 }
开发者ID:EraYaN,项目名称:EV2020,代码行数:8,代码来源:DenseVector.cs

示例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()));
 }
开发者ID:Jungwon,项目名称:mathnet-numerics,代码行数:8,代码来源:DenseVector.cs

示例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);
 }
开发者ID:hrapa,项目名称:mathnet-numerics,代码行数:12,代码来源:DenseMatrix.cs

示例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;
        }
开发者ID:hany-abdelrahman,项目名称:mathnet-numerics,代码行数:25,代码来源:SparseVector.cs

示例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;
        }
开发者ID:vivektewari,项目名称:mathnet-numerics,代码行数:37,代码来源:Matrix.Arithmetic.cs

示例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;
        }
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:25,代码来源:DenseVector.cs

示例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;
        }
开发者ID:rafaortega,项目名称:mathnet-numerics,代码行数:38,代码来源:SparseMatrix.cs


注:本文中的IContinuousDistribution.Sample方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。