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


C# Distributions.LogNormal类代码示例

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


LogNormal类属于MathNet.Numerics.Distributions命名空间,在下文中一共展示了LogNormal类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CanEstimateParameters

        public void CanEstimateParameters(double mu, double sigma)
        {
            var original = new LogNormal(mu, sigma, new Random(100));
            var estimated = LogNormal.Estimate(original.Samples().Take(10000));

            AssertHelpers.AlmostEqualRelative(mu, estimated.Mu, 1);
            AssertHelpers.AlmostEqualRelative(sigma, estimated.Sigma, 1);
        }
开发者ID:kityandhero,项目名称:mathnet-numerics,代码行数:8,代码来源:LogNormalTests.cs

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

示例3: ValidateMean

 public void ValidateMean(double mu, double sigma, double mean)
 {
     var n = new LogNormal(mu, sigma);
     AssertHelpers.AlmostEqualRelative(mean, n.Mean, 14);
 }
开发者ID:kityandhero,项目名称:mathnet-numerics,代码行数:5,代码来源:LogNormalTests.cs

示例4: ValidateMaximum

 public void ValidateMaximum()
 {
     var n = new LogNormal(1.0, 2.0);
     Assert.AreEqual(Double.PositiveInfinity, n.Maximum);
 }
开发者ID:kityandhero,项目名称:mathnet-numerics,代码行数:5,代码来源:LogNormalTests.cs

示例5: LogNormalCreateFailsWithBadParameters

 public void LogNormalCreateFailsWithBadParameters(double mu, double sigma)
 {
     var n = new LogNormal(mu, sigma);
 }
开发者ID:joeynelson,项目名称:mathnet-numerics,代码行数:4,代码来源:LogNormalTests.cs

示例6: Run

        /// <summary>
        /// Run example
        /// </summary>
        /// <a href="http://en.wikipedia.org/wiki/Log-normal_distribution">LogNormal distribution</a>
        public void Run()
        {
            // 1. Initialize the new instance of the LogNormal distribution class with parameters Mu = 0, Sigma = 1
            var logNormal = new LogNormal(0, 1);
            Console.WriteLine(@"1. Initialize the new instance of the LogNormal distribution class with parameters Mu = {0}, Sigma = {1}", logNormal.Mu, logNormal.Sigma);
            Console.WriteLine();

            // 2. Distributuion properties:
            Console.WriteLine(@"2. {0} distributuion properties:", logNormal);

            // Cumulative distribution function
            Console.WriteLine(@"{0} - Сumulative distribution at location '0.3'", logNormal.CumulativeDistribution(0.3).ToString(" #0.00000;-#0.00000"));

            // Probability density
            Console.WriteLine(@"{0} - Probability density at location '0.3'", logNormal.Density(0.3).ToString(" #0.00000;-#0.00000"));

            // Log probability density
            Console.WriteLine(@"{0} - Log probability density at location '0.3'", logNormal.DensityLn(0.3).ToString(" #0.00000;-#0.00000"));

            // Entropy
            Console.WriteLine(@"{0} - Entropy", logNormal.Entropy.ToString(" #0.00000;-#0.00000"));

            // Largest element in the domain
            Console.WriteLine(@"{0} - Largest element in the domain", logNormal.Maximum.ToString(" #0.00000;-#0.00000"));

            // Smallest element in the domain
            Console.WriteLine(@"{0} - Smallest element in the domain", logNormal.Minimum.ToString(" #0.00000;-#0.00000"));

            // Mean
            Console.WriteLine(@"{0} - Mean", logNormal.Mean.ToString(" #0.00000;-#0.00000"));

            // Median
            Console.WriteLine(@"{0} - Median", logNormal.Median.ToString(" #0.00000;-#0.00000"));

            // Mode
            Console.WriteLine(@"{0} - Mode", logNormal.Mode.ToString(" #0.00000;-#0.00000"));

            // Variance
            Console.WriteLine(@"{0} - Variance", logNormal.Variance.ToString(" #0.00000;-#0.00000"));

            // Standard deviation
            Console.WriteLine(@"{0} - Standard deviation", logNormal.StdDev.ToString(" #0.00000;-#0.00000"));

            // Skewness
            Console.WriteLine(@"{0} - Skewness", logNormal.Skewness.ToString(" #0.00000;-#0.00000"));
            Console.WriteLine();

            // 3. Generate 10 samples
            Console.WriteLine(@"3. Generate 10 samples");
            for (var i = 0; i < 10; i++)
            {
                Console.Write(logNormal.Sample().ToString("N05") + @" ");
            }

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

            // 4. Generate 100000 samples of the LogNormal(0, 1) distribution and display histogram
            Console.WriteLine(@"4. Generate 100000 samples of the LogNormal(0, 1) distribution and display histogram");
            var data = new double[100000];
            for (var i = 0; i < data.Length; i++)
            {
                data[i] = logNormal.Sample();
            }

            ConsoleHelper.DisplayHistogram(data);
            Console.WriteLine();

            // 5. Generate 100000 samples of the LogNormal(0, 0.5) distribution and display histogram
            Console.WriteLine(@"5. Generate 100000 samples of the LogNormal(0, 0.5) distribution and display histogram");
            logNormal.Sigma = 0.5;
            for (var i = 0; i < data.Length; i++)
            {
                data[i] = logNormal.Sample();
            }

            ConsoleHelper.DisplayHistogram(data);
            Console.WriteLine();

            // 6. Generate 100000 samples of the LogNormal(5, 0.25) distribution and display histogram
            Console.WriteLine(@"6. Generate 100000 samples of the LogNormal(5, 0.25) distribution and display histogram");
            logNormal.Mu = 5;
            logNormal.Sigma = 0.25;
            for (var i = 0; i < data.Length; i++)
            {
                data[i] = logNormal.Sample();
            }

            ConsoleHelper.DisplayHistogram(data);
        }
开发者ID:Mistrall,项目名称:Solvation,代码行数:94,代码来源:LogNormalDistribution.cs

示例7: ValidateToString

 public void ValidateToString()
 {
     var n = new LogNormal(1d, 2d);
     Assert.AreEqual("LogNormal(μ = 1, σ = 2)", n.ToString());
 }
开发者ID:kityandhero,项目名称:mathnet-numerics,代码行数:5,代码来源:LogNormalTests.cs

示例8: ValidateMode

 public void ValidateMode(double mu, double sigma, double mode)
 {
     var n = new LogNormal(mu, sigma);
     Assert.AreEqual(mode, n.Mode);
 }
开发者ID:kityandhero,项目名称:mathnet-numerics,代码行数:5,代码来源:LogNormalTests.cs

示例9: CanSampleSequence

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

示例10: ValidateDensity

 public void ValidateDensity(double mu, double sigma, double x, double p)
 {
     var n = new LogNormal(mu, sigma);
     AssertHelpers.AlmostEqual(p, n.Density(x), 14);
     AssertHelpers.AlmostEqual(p, LogNormal.PDF(mu, sigma, x), 14);
 }
开发者ID:nakamoton,项目名称:mathnet-numerics,代码行数:6,代码来源:LogNormalTests.cs

示例11: SetSigmaFailsWithNegativeSigma

 public void SetSigmaFailsWithNegativeSigma()
 {
     var n = new LogNormal(1.0, 2.0);
     Assert.Throws<ArgumentOutOfRangeException>(() => n.Sigma = -1.0);
 }
开发者ID:nakamoton,项目名称:mathnet-numerics,代码行数:5,代码来源:LogNormalTests.cs

示例12: CanSetMu

 public void CanSetMu(double mu)
 {
     var n = new LogNormal(1.0, 2.0);
     n.Mu = mu;
 }
开发者ID:joeynelson,项目名称:mathnet-numerics,代码行数:5,代码来源:LogNormalTests.cs

示例13: ValidateToString

 public void ValidateToString()
 {
     var n = new LogNormal(1.0, 2.0);
     AssertEx.AreEqual<string>("LogNormal(Mu = 1, Sigma = 2)", n.ToString());
 }
开发者ID:joeynelson,项目名称:mathnet-numerics,代码行数:5,代码来源:LogNormalTests.cs

示例14: SetSigmaFailsWithNegativeSigma

 public void SetSigmaFailsWithNegativeSigma()
 {
     var n = new LogNormal(1.0, 2.0);
     n.Sigma = -1.0;
 }
开发者ID:joeynelson,项目名称:mathnet-numerics,代码行数:5,代码来源:LogNormalTests.cs

示例15: ValidateMedian

 public void ValidateMedian(double mu, double sigma, double median)
 {
     var n = new LogNormal(mu, sigma);
     Assert.AreEqual(median, n.Median);
 }
开发者ID:kityandhero,项目名称:mathnet-numerics,代码行数:5,代码来源:LogNormalTests.cs


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