• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Distributions.ContinuousUniform类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中MathNet.Numerics.Distributions.ContinuousUniform的典型用法代码示例。如果您正苦于以下问题:C# ContinuousUniform类的具体用法?C# ContinuousUniform怎么用?C# ContinuousUniform使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ContinuousUniform类属于MathNet.Numerics.Distributions命名空间,在下文中一共展示了ContinuousUniform类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: ZergCharacter

        static ZergCharacter()
        {
            GOAL_PRIORITIES = new Dictionary<State, byte>(){
                {State.AttackGoal, 16},
                {State.FeedGoal, 8},
                {State.RetreatGoal, 1},
                {State.ServeGoal, 2}
            };

            var goals = new Stack<State>();

            var goalEnums = (State[])Enum.GetValues(typeof(State));
            foreach (var enumValue in goalEnums)
            {
                for (int i = 0; i < GOAL_PRIORITIES[enumValue]; i++)
                {
                    goals.Push(enumValue);
                }
            }

            int count = goals.Count;
            RND = new DiscreteUniform(0, count - 1);
            GOALS_LOOKUP_TABLE = new State[count];

            var rnd = new ContinuousUniform(0.0, 1.0);

            while (goals.Any())
            {
                int idx = (int)Math.Round(rnd.Sample() * (--count), 0);
                GOALS_LOOKUP_TABLE[idx] = goals.Pop();
            }
        }
开发者ID:homoluden,项目名称:GenAI,代码行数:32,代码来源:ZergCharacter.cs


示例3: Build

        /// <summary>
        /// Build linear samples.
        /// </summary>
        /// <param name="x">X sample values.</param>
        /// <param name="y">Y samples values.</param>
        /// <param name="xtest">X test values.</param>
        /// <param name="ytest">Y test values.</param>
        /// <param name="samples">Sample values.</param>
        /// <param name="sampleOffset">Sample offset.</param>
        /// <param name="slope">Slope number.</param>
        /// <param name="intercept">Intercept criteria.</param>
        public static void Build(out double[] x, out double[] y, out double[] xtest, out double[] ytest, int samples = 3, double sampleOffset = -0.5, double slope = 2.0, double intercept = -1.0)
        {
            // Fixed-seed "random" distribution to ensure we always test with the same data
            var uniform = new ContinuousUniform(0.0, 1.0, new SystemRandomSource(42));

            // build linear samples
            x = new double[samples];
            y = new double[samples];
            for (int i = 0; i < x.Length; i++)
            {
                x[i] = i + sampleOffset;
                y[i] = (x[i]*slope) + intercept;
            }

            // build linear test vectors randomly between the sample points
            xtest = new double[samples + 1];
            ytest = new double[samples + 1];
            if (samples == 1)
            {
                // y = const
                xtest[0] = sampleOffset - uniform.Sample();
                xtest[1] = sampleOffset + uniform.Sample();
                ytest[0] = ytest[1] = (sampleOffset*slope) + intercept;
            }
            else
            {
                for (int i = 0; i < xtest.Length; i++)
                {
                    xtest[i] = (i - 1) + sampleOffset + uniform.Sample();
                    ytest[i] = (xtest[i]*slope) + intercept;
                }
            }
        }
开发者ID:skair39,项目名称:mathnet-numerics,代码行数:44,代码来源:LinearInterpolationCase.cs


示例4: RejectTest

        public void RejectTest()
        {
            var uniform = new ContinuousUniform(0.0, 1.0, new SystemRandomSource(1));
            var rs = new RejectionSampler<double>(x => Math.Pow(x, 1.7)*Math.Pow(1.0 - x, 5.3), x => 0.021, uniform.Sample);
            Assert.IsNotNull(rs.RandomSource);

            rs.RandomSource = uniform.RandomSource;
            Assert.IsNotNull(rs.RandomSource);
        }
开发者ID:larzw,项目名称:mathnet-numerics,代码行数:9,代码来源:RejectionSamplerTests.cs


示例5: NullRandomNumberGenerator

        public void NullRandomNumberGenerator()
        {
            var uniform = new ContinuousUniform(0.0, 1.0);
            uniform.RandomSource = new MersenneTwister();

            var rs = new RejectionSampler<double>(x => System.Math.Pow(x, 1.7) * System.Math.Pow(1.0 - x, 5.3),
                                                  x => System.Double.NegativeInfinity,
                                                  uniform.Sample);
            rs.RandomSource = null;
        }
开发者ID:joeynelson,项目名称:mathnet-numerics,代码行数:10,代码来源:RejectionSamplerTests.cs


示例6: NoUpperBound

        public void NoUpperBound()
        {
            var uniform = new ContinuousUniform(0.0, 1.0);
            uniform.RandomSource = new MersenneTwister();

            var rs = new RejectionSampler<double>(x => System.Math.Pow(x, 1.7) * System.Math.Pow(1.0 - x, 5.3),
                                                  x => System.Double.NegativeInfinity,
                                                  uniform.Sample);
            double s = rs.Sample();
        }
开发者ID:joeynelson,项目名称:mathnet-numerics,代码行数:10,代码来源:RejectionSamplerTests.cs


示例7: SampleArrayTest

        public void SampleArrayTest()
        {
            var uniform = new ContinuousUniform(0.0, 1.0, new SystemRandomSource(1));

            var rs = new RejectionSampler<double>(x => Math.Pow(x, 1.7)*Math.Pow(1.0 - x, 5.3), x => 0.021, uniform.Sample)
                {
                    RandomSource = uniform.RandomSource
                };

            rs.Sample(5);
        }
开发者ID:larzw,项目名称:mathnet-numerics,代码行数:11,代码来源:RejectionSamplerTests.cs


示例8: SetupDistributions

        public void SetupDistributions()
        {
            dists = new IDistribution[8];

            dists[0] = new Beta(1.0, 1.0);
            dists[1] = new ContinuousUniform(0.0, 1.0);
            dists[2] = new Gamma(1.0, 1.0);
            dists[3] = new Normal(0.0, 1.0);
            dists[4] = new Bernoulli(0.6);
            dists[5] = new Weibull(1.0, 1.0);
            dists[6] = new DiscreteUniform(1, 10);
            dists[7] = new LogNormal(1.0, 1.0);
        }
开发者ID:DvptUml,项目名称:mathnet-numerics,代码行数:13,代码来源:CommonDistributionTests.cs


示例9: 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


示例10: RejectTest

        public void RejectTest()
        {
            var uniform = new ContinuousUniform(0.0, 1.0);
            uniform.RandomSource = new MersenneTwister();

            var rs = new RejectionSampler<double>(x => System.Math.Pow(x, 1.7) * System.Math.Pow(1.0 - x, 5.3),
                                                  x => 0.021,
                                                  uniform.Sample);
            Assert.IsNotNull(rs.RandomSource);

            rs.RandomSource = uniform.RandomSource;
            Assert.IsNotNull(rs.RandomSource);
        }
开发者ID:joeynelson,项目名称:mathnet-numerics,代码行数:13,代码来源:RejectionSamplerTests.cs


示例11: Run

        /// <summary>
        /// Run example
        /// </summary>
        public void Run()
        {
            // 1. Get 10 random samples of f(x) = (x * x) / 2 using continuous uniform distribution on [-10, 10]
            var uniform = new ContinuousUniform(-10, 10);
            var result = Generate.RandomMap(10, uniform, Function);
            Console.WriteLine(@" 1. Get 10 random samples of f(x) = (x * x) / 2 using continuous uniform distribution on [-10, 10]");
            for (var i = 0; i < result.Length; i++)
            {
                Console.Write(result[i].ToString("N") + @" ");
            }

            Console.WriteLine();
            Console.WriteLine();

            // 2. Get 10 random samples of f(x) = (x * x) / 2 using Exponential(1) distribution and retrieve sample points
            var exponential = new Exponential(1);
            double[] samplePoints = Generate.Random(10, exponential);
            result = Generate.Map(samplePoints, Function);
            Console.WriteLine(@"2. Get 10 random samples of f(x) = (x * x) / 2 using Exponential(1) distribution and retrieve sample points");
            Console.Write(@"Points: ");
            for (var i = 0; i < samplePoints.Length; i++)
            {
                Console.Write(samplePoints[i].ToString("N") + @" ");
            }

            Console.WriteLine();
            Console.Write(@"Values: ");
            for (var i = 0; i < result.Length; i++)
            {
                Console.Write(result[i].ToString("N") + @" ");
            }

            Console.WriteLine();
            Console.WriteLine();

            // 3. Get 10 random samples of f(x, y) = (x * y) / 2 using ChiSquare(10) distribution
            var chiSquare = new ChiSquared(10);
            result = Generate.RandomMap2(10, chiSquare, TwoDomainFunction);
            Console.WriteLine(@" 3. Get 10 random samples of f(x, y) = (x * y) / 2 using ChiSquare(10) distribution");
            for (var i = 0; i < result.Length; i++)
            {
                Console.Write(result[i].ToString("N") + @" ");
            }

            Console.WriteLine();
        }
开发者ID:Jungwon,项目名称:mathnet-numerics,代码行数:49,代码来源:Random.cs


示例12: ShowErrorInfer3DExactLMS

        /// <summary>
        /// Uses Infer3DExactLMS to infer a random world point from a number of different projections of the point.
        /// It writes out the squared errors corresponding to different number of projections into a file.
        /// </summary>
        /// <param name="numProjections">the max number of projections to use.</param>
        /// <param name="gaussianNoiseSigma">the standard deviation of the gaussian noise to be added to the projected points.</param>
        public static void ShowErrorInfer3DExactLMS(int numProjections, double gaussianNoiseSigma, string fileName)
        {
            ContinuousUniform dist = new ContinuousUniform(0, 1);
            Normal gaussianNoise = new Normal(0, gaussianNoiseSigma);
            DenseMatrix worldPoint = new DenseMatrix(4,1);
            worldPoint = (DenseMatrix) worldPoint.Random(4,1, dist);
            ProjectedPoint[] projections = new ProjectedPoint[numProjections];

            for (int i = 0; i < projections.Length; i++)
            {
                projections[i] = new ProjectedPoint();
                projections[i].worldToImage = new DenseMatrix(3, 4);
                projections[i].worldToImage = (DenseMatrix)projections[i].worldToImage.Random(3, 4, dist);
                projections[i].projectedPoint = (projections[i].worldToImage * worldPoint);
                projections[i].projectedPoint += (DenseMatrix)projections[i].projectedPoint.Random(3, 1, gaussianNoise);
            }

            File.WriteAllLines(fileName,
                Enumerable.Range(2, numProjections)
                    .Select(i => String.Format("{0}\t{1}", i, (worldPoint - Infer3DExactLMS(projections.Take(i))).L2Norm())));
        }
开发者ID:kamal-kr,项目名称:StartTrek,代码行数:27,代码来源:InferWorld.cs


示例13: DenseDiagonalMatrixTransposeAndMultiply

        public void DenseDiagonalMatrixTransposeAndMultiply()
        {
            var dist = new ContinuousUniform(-1.0, 1.0, new SystemRandomSource(1));
            Assert.IsInstanceOf<DiagonalMatrix>(Matrix<Complex>.Build.DiagonalIdentity(3, 3));

            var tall = Matrix<Complex>.Build.Random(8, 3, dist);
            Assert.IsTrue(tall.TransposeAndMultiply(Matrix<Complex>.Build.DiagonalIdentity(3).Multiply(2d)).Equals(tall.Multiply(2d)));
            Assert.IsTrue(tall.TransposeAndMultiply(Matrix<Complex>.Build.Diagonal(5, 3, 2d)).Equals(tall.Multiply(2d).Append(Matrix<Complex>.Build.Dense(8, 2))));
            Assert.IsTrue(tall.TransposeAndMultiply(Matrix<Complex>.Build.Diagonal(2, 3, 2d)).Equals(tall.Multiply(2d).SubMatrix(0, 8, 0, 2)));

            var wide = Matrix<Complex>.Build.Random(3, 8, dist);
            Assert.IsTrue(wide.TransposeAndMultiply(Matrix<Complex>.Build.DiagonalIdentity(8).Multiply(2d)).Equals(wide.Multiply(2d)));
            Assert.IsTrue(wide.TransposeAndMultiply(Matrix<Complex>.Build.Diagonal(10, 8, 2d)).Equals(wide.Multiply(2d).Append(Matrix<Complex>.Build.Dense(3, 2))));
            Assert.IsTrue(wide.TransposeAndMultiply(Matrix<Complex>.Build.Diagonal(2, 8, 2d)).Equals(wide.Multiply(2d).SubMatrix(0, 3, 0, 2)));
        }
开发者ID:skair39,项目名称:mathnet-numerics,代码行数:15,代码来源:DiagonalMatrixTests.cs


示例14: ValidateInverseCumulativeDistribution

 public void ValidateInverseCumulativeDistribution(double lower, double upper)
 {
     var n = new ContinuousUniform(lower, upper);
     for (var i = 0; i < 11; i++)
     {
         var x = i - 5.0;
         if (x <= lower)
         {
             Assert.AreEqual(lower, n.InverseCumulativeDistribution(0.0), 1e-12);
             Assert.AreEqual(lower, ContinuousUniform.InvCDF(lower, upper, 0.0), 1e-12);
         }
         else if (x >= upper)
         {
             Assert.AreEqual(upper, n.InverseCumulativeDistribution(1.0), 1e-12);
             Assert.AreEqual(upper, ContinuousUniform.InvCDF(lower, upper, 1.0), 1e-12);
         }
         else
         {
             Assert.AreEqual(x, n.InverseCumulativeDistribution((x - lower)/(upper - lower)), 1e-12);
             Assert.AreEqual(x, ContinuousUniform.InvCDF(lower, upper, (x - lower)/(upper - lower)), 1e-12);
         }
     }
 }
开发者ID:rmundy,项目名称:mathnet-numerics,代码行数:23,代码来源:ContinuousUniformTests.cs


示例15: CreateSampleObject

        /// <summary>
        /// Creates the list of objects with specified class
        /// </summary>
        /// <param name="generator"></param>
        /// <param name="count"></param>
        /// <param name="classNumber"></param>
        /// <returns></returns>
        public static List<PatternClass> CreateSampleObject(int p1,int p2 ,IContinuousDistribution generator1,IContinuousDistribution generator2,int count)
        {
            List<PatternClass> sampleObjects = new List<PatternClass>();
            probabilityGenerator = new ContinuousUniform(0, 1);
            probabilityGenerator.RandomSource = new Random(DateTime.Now.Millisecond + 10);

            int counter = 0; ;
            for (; counter < count; )
            {
                //sampleObjects.Add(new PatternClass(new FeatureVector(generator.Sample()), classNumber));
            }
            return sampleObjects;
        }
开发者ID:michal-franc,项目名称:ImageClassification,代码行数:20,代码来源:Common.cs


示例16: ValidateMode

 public void ValidateMode(double lower, double upper)
 {
     var n = new ContinuousUniform(lower, upper);
     Assert.AreEqual((lower + upper) / 2.0, n.Mode);
 }
开发者ID:rmundy,项目名称:mathnet-numerics,代码行数:5,代码来源:ContinuousUniformTests.cs


示例17: ValidateMinimum

 public void ValidateMinimum(double lower, double upper)
 {
     var n = new ContinuousUniform(lower, upper);
     Assert.AreEqual(lower, n.Minimum);
 }
开发者ID:rmundy,项目名称:mathnet-numerics,代码行数:5,代码来源:ContinuousUniformTests.cs


示例18: CanSampleSequence

 public void CanSampleSequence()
 {
     var n = new ContinuousUniform();
     var ied = n.Samples();
     ied.Take(5).ToArray();
 }
开发者ID:rmundy,项目名称:mathnet-numerics,代码行数:6,代码来源:ContinuousUniformTests.cs


示例19: NoUpperBound

 public void NoUpperBound()
 {
     var uniform = new ContinuousUniform(0.0, 1.0, new SystemRandomSource(1));
     var rs = new RejectionSampler<double>(x => Math.Pow(x, 1.7)*Math.Pow(1.0 - x, 5.3), x => Double.NegativeInfinity, uniform.Sample);
     Assert.That(() => rs.Sample(), Throws.ArgumentException);
 }
开发者ID:larzw,项目名称:mathnet-numerics,代码行数:6,代码来源:RejectionSamplerTests.cs


示例20: NullRandomNumberGenerator

 public void NullRandomNumberGenerator()
 {
     var uniform = new ContinuousUniform(0.0, 1.0, new SystemRandomSource(1));
     var rs = new RejectionSampler<double>(x => Math.Pow(x, 1.7)*Math.Pow(1.0 - x, 5.3), x => Double.NegativeInfinity, uniform.Sample);
     Assert.That(() => rs.RandomSource = null, Throws.TypeOf<ArgumentNullException>());
 }
开发者ID:larzw,项目名称:mathnet-numerics,代码行数:6,代码来源:RejectionSamplerTests.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Distributions.Gamma类代码示例发布时间:2022-05-26
下一篇:
C# Distributions.ChiSquared类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap