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


C# Normal.Sample方法代码示例

本文整理汇总了C#中Normal.Sample方法的典型用法代码示例。如果您正苦于以下问题:C# Normal.Sample方法的具体用法?C# Normal.Sample怎么用?C# Normal.Sample使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Normal的用法示例。


在下文中一共展示了Normal.Sample方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GenerateRandomDenseMatrix

        /// <summary>
        /// Creates a <c>DenseMatrix</c> with random values.
        /// </summary>
        /// <param name="row">The number of rows.</param>
        /// <param name="col">The number of columns.</param>
        /// <returns>A <c>DenseMatrix</c> with the given dimensions and random values.</returns>
        public static Matrix GenerateRandomDenseMatrix(int row, int col)
        {
            // Fill a matrix with standard random numbers.
            var normal = new Normal
                         {
                             RandomSource = new MersenneTwister(1)
                         };
            var matrixA = new DenseMatrix(row, col);
            for (var i = 0; i < row; i++)
            {
                for (var j = 0; j < col; j++)
                {
                    matrixA[i, j] = normal.Sample();
                }
            }

            return matrixA;
        }
开发者ID:nrolland,项目名称:mathnet-numerics,代码行数:24,代码来源:MatrixLoader.cs

示例2: CanSample

 public void CanSample()
 {
     var n = new Normal();
     n.Sample();
 }
开发者ID:KeithVanderzanden,项目名称:mmbot,代码行数:5,代码来源:WeibullTests.cs

示例3: GenerateRandomUserDefinedVector

        /// <summary>
        /// Creates a <c>UserDefinedVector</c> with random values.
        /// </summary>
        /// <param name="order">The size of the vector.</param>
        /// <returns>A <c>UserDefinedVector</c> with the given dimension and random values.</returns>
        public static Vector GenerateRandomUserDefinedVector(int order)
        {
            // Fill a matrix with standard random numbers.
            var normal = new Normal
                {
                    RandomSource = new MersenneTwister(1)
                };
            var v = new UserDefinedVector(order);
            for (var i = 0; i < order; i++)
            {
                v[i] = new Complex(normal.Sample(), normal.Sample());
            }

            // Generate a matrix which is positive definite.
            return v;
        }
开发者ID:hickford,项目名称:mathnet-numerics-native,代码行数:21,代码来源:MatrixLoader.cs

示例4: GenerateRandomPositiveDefiniteHermitianUserDefinedMatrix

        /// <summary>
        /// Creates a positive definite <c>UserDefinedMatrix</c> with random values.
        /// </summary>
        /// <param name="order">The order of the matrix.</param>
        /// <returns>A positive definite <c>UserDefinedMatrix</c> with the given order and random values.</returns>
        public static Matrix<Complex> GenerateRandomPositiveDefiniteHermitianUserDefinedMatrix(int order)
        {
            // Fill a matrix with standard random numbers.
            var normal = new Normal
                {
                    RandomSource = new MersenneTwister(1)
                };
            var matrixA = new UserDefinedMatrix(order);
            for (var i = 0; i < order; i++)
            {
                for (var j = 0; j < order; j++)
                {
                    matrixA[i, j] = new Complex(normal.Sample(), normal.Sample());
                }
            }

            // Generate a Hermitian matrix which is positive definite.
            return matrixA.ConjugateTranspose()*matrixA;
        }
开发者ID:hickford,项目名称:mathnet-numerics-native,代码行数:24,代码来源:MatrixLoader.cs

示例5: GenerateRandomDenseVector

        /// <summary>
        /// Creates a <c>DenseVector</c> with random values.
        /// </summary>
        /// <param name="order">The size of the vector.</param>
        /// <returns>A <c>DenseVector</c> with the given dimension and random values.</returns>
        public static Vector GenerateRandomDenseVector(int order)
        {
            // Fill a matrix with standard random numbers.
            var normal = new Normal
                {
                    RandomSource = new MersenneTwister(1)
                };
            var v = new DenseVector(order);
            for (var i = 0; i < order; i++)
            {
                v[i] = new Complex(normal.Sample(), normal.Sample());
            }

            return v;
        }
开发者ID:hickford,项目名称:mathnet-numerics-native,代码行数:20,代码来源:MatrixLoader.cs

示例6: GenerateRandomPositiveDefiniteUserDefinedMatrix

        /// <summary>
        /// Creates a positive definite <c>UserDefinedMatrix</c> with random values.
        /// </summary>
        /// <param name="order">The order of the matrix.</param>
        /// <returns>A positive definite <c>UserDefinedMatrix</c> with the given order and random values.</returns>
        public static Matrix<double> GenerateRandomPositiveDefiniteUserDefinedMatrix(int order)
        {
            // Fill a matrix with standard random numbers.
            var normal = new Normal(new MersenneTwister(1));
            var matrixA = new UserDefinedMatrix(order);
            for (var i = 0; i < order; i++)
            {
                for (var j = 0; j < order; j++)
                {
                    matrixA[i, j] = normal.Sample();
                }
            }

            // Generate a matrix which is positive definite.
            return matrixA.Transpose()*matrixA;
        }
开发者ID:koponk,项目名称:mathnet-numerics,代码行数:21,代码来源:MatrixLoader.cs

示例7: GenerateRandomPositiveDefiniteDenseMatrix

        /// <summary>
        /// Creates a positive definite <c>DenseMatrix</c> with random values.
        /// </summary>
        /// <param name="order">The order of the matrix.</param>
        /// <returns>A positive definite <c>DenseMatrix</c> with the given order and random values.</returns>
        public static Matrix<float> GenerateRandomPositiveDefiniteDenseMatrix(int order)
        {
            // Fill a matrix with standard random numbers.
            var normal = new Normal
                {
                    RandomSource = new MersenneTwister(1)
                };
            var matrixA = new DenseMatrix(order);
            for (var i = 0; i < order; i++)
            {
                for (var j = 0; j < order; j++)
                {
                    matrixA[i, j] = (float) normal.Sample();
                }
            }

            // Generate a matrix which is positive definite.
            return matrixA.Transpose()*matrixA;
        }
开发者ID:hickford,项目名称:mathnet-numerics-native,代码行数:24,代码来源:MatrixLoader.cs

示例8: GenerateRandomUserDefinedMatrix

        /// <summary>
        /// Creates a <c>UserDefinedMatrix</c> with random values.
        /// </summary>
        /// <param name="row">The number of rows.</param>
        /// <param name="col">The number of columns.</param>
        /// <returns>A <c>UserDefinedMatrix</c> with the given dimensions and random values.</returns>
        public static Matrix GenerateRandomUserDefinedMatrix(int row, int col)
        {
            // Fill a matrix with standard random numbers.
            var normal = new Normal(new MersenneTwister(1));
            var matrixA = new UserDefinedMatrix(row, col);
            for (var i = 0; i < row; i++)
            {
                for (var j = 0; j < col; j++)
                {
                    matrixA[i, j] = new Complex32((float) normal.Sample(), (float) normal.Sample());
                }
            }

            return matrixA;
        }
开发者ID:koponk,项目名称:mathnet-numerics,代码行数:21,代码来源:MatrixLoader.cs

示例9: GenerateRandomPositiveDefiniteHermitianDenseMatrix

        /// <summary>
        /// Creates a positive definite <c>DenseMatrix</c> with random values.
        /// </summary>
        /// <param name="order">The order of the matrix.</param>
        /// <returns>A positive definite <c>DenseMatrix</c> with the given order and random values.</returns>
        public static Matrix<Complex32> GenerateRandomPositiveDefiniteHermitianDenseMatrix(int order)
        {
            // Fill a matrix with standard random numbers.
            var normal = new Normal(new MersenneTwister(1));
            var matrixA = new DenseMatrix(order);
            for (var i = 0; i < order; i++)
            {
                for (var j = 0; j < order; j++)
                {
                    matrixA[i, j] = new Complex32((float) normal.Sample(), (float) normal.Sample());
                }
            }

            // Generate a Hermitian matrix which is positive definite.
            return matrixA.ConjugateTranspose()*matrixA;
        }
开发者ID:koponk,项目名称:mathnet-numerics,代码行数:21,代码来源:MatrixLoader.cs

示例10: GenerateRandomDenseVector

        /// <summary>
        /// Creates a <c>DenseVector</c> with random values.
        /// </summary>
        /// <param name="order">The size of the vector.</param>
        /// <returns>A <c>DenseVector</c> with the given dimension and random values.</returns>
        public static Vector GenerateRandomDenseVector(int order)
        {
            // Fill a matrix with standard random numbers.
            var normal = new Normal(new MersenneTwister(1));
            var v = new DenseVector(order);
            for (var i = 0; i < order; i++)
            {
                v[i] = (float) normal.Sample();
            }

            return v;
        }
开发者ID:koponk,项目名称:mathnet-numerics,代码行数:17,代码来源:MatrixLoader.cs

示例11: CreateStartingVectors

        /// <summary>
        /// Returns an array of starting vectors.
        /// </summary>
        /// <param name="maximumNumberOfStartingVectors">The maximum number of starting vectors that should be created.</param>
        /// <param name="numberOfVariables">The number of variables.</param>
        /// <returns>
        ///  An array with starting vectors. The array will never be larger than the
        ///  <paramref name="maximumNumberOfStartingVectors"/> but it may be smaller if
        ///  the <paramref name="numberOfVariables"/> is smaller than 
        ///  the <paramref name="maximumNumberOfStartingVectors"/>.
        /// </returns>
        private static IList<Vector> CreateStartingVectors(int maximumNumberOfStartingVectors, int numberOfVariables)
        {
            // Create no more starting vectors than the size of the problem - 1
            // Get random values and then orthogonalize them with
            // modified Gramm - Schmidt
            var count = NumberOfStartingVectorsToCreate(maximumNumberOfStartingVectors, numberOfVariables);

            // Get a random set of samples based on the standard normal distribution with
            // mean = 0 and sd = 1
            var distribution = new Normal();

            Matrix matrix = new DenseMatrix(numberOfVariables, count);
            for (var i = 0; i < matrix.ColumnCount; i++)
            {
                var samples = new float[matrix.RowCount];
                for (var j = 0; j < matrix.RowCount; j++)
                {
                    samples[j] = (float)distribution.Sample();
                }
                
                // Set the column
                matrix.SetColumn(i, samples);
            }

            // Compute the orthogonalization.
            var gs = matrix.GramSchmidt();
            var orthogonalMatrix = gs.Q;

            // Now transfer this to vectors
            var result = new List<Vector>();
            for (var i = 0; i < orthogonalMatrix.ColumnCount; i++)
            {
                result.Add((Vector)orthogonalMatrix.Column(i));
                
                // Normalize the result vector
                result[i].Multiply(1 / result[i].Norm(2), result[i]);
            }

            return result;
        }
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:51,代码来源:MlkBiCgStab.cs


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