C# NormalDistribution类代码示例(c#normaldistribution类的典型用法)

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


C# NormalDistribution类代码示例(c#normaldistribution类的典型用法)

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

示例1: ProbabilityFunctionTest

 public void ProbabilityFunctionTest()
        {
            var p1 = new NormalDistribution(4.2, 1);
            var p2 = new NormalDistribution(7.0, 2);

            Independent<NormalDistribution> target = new Independent<NormalDistribution>(p1, p2);

            double[] x;
            double actual, expected;

            x = new double[] { 4.2, 7.0 };
            actual = target.ProbabilityDensityFunction(x);
            expected = p1.ProbabilityDensityFunction(x[0]) * p2.ProbabilityDensityFunction(x[1]);
            Assert.AreEqual(expected, actual, 1e-10);
            Assert.IsFalse(double.IsNaN(actual));

            x = new double[] { 0.0, 0.0 };
            actual = target.ProbabilityDensityFunction(x);
            expected = p1.ProbabilityDensityFunction(x[0]) * p2.ProbabilityDensityFunction(x[1]);
            Assert.AreEqual(expected, actual, 1e-10);
            Assert.IsFalse(double.IsNaN(actual));

            x = new double[] { 7.0, 4.2 };
            actual = target.ProbabilityDensityFunction(x);
            expected = p1.ProbabilityDensityFunction(x[0]) * p2.ProbabilityDensityFunction(x[1]);
            Assert.AreEqual(expected, actual, 1e-10);
            Assert.IsFalse(double.IsNaN(actual));
        }
开发者ID:RLaumeyer,项目名称:framework,代码行数:28,代码来源:IndependentTest.cs

示例2: ConstructorTest

 public void ConstructorTest()
        {
            var p1 = new NormalDistribution(4.2, 1);
            var p2 = new NormalDistribution(7.0, 2);

            Independent<NormalDistribution> target = new Independent<NormalDistribution>(p1, p2);

            Assert.AreEqual(target.Components[0], p1);
            Assert.AreEqual(target.Components[1], p2);

            Assert.AreEqual(2, target.Dimension);

            Assert.AreEqual(4.2, target.Mean[0]);
            Assert.AreEqual(7.0, target.Mean[1]);

            Assert.AreEqual(1, target.Variance[0]);
            Assert.AreEqual(4, target.Variance[1]);

            Assert.AreEqual(1, target.Covariance[0, 0]);
            Assert.AreEqual(4, target.Covariance[1, 1]);
            Assert.AreEqual(0, target.Covariance[0, 1]);
            Assert.AreEqual(0, target.Covariance[1, 0]);

            var text = target.ToString("N2", System.Globalization.CultureInfo.InvariantCulture);

            Assert.AreEqual("Independent(x0, x1; N(x0; μ = 4.20, σ² = 1.00) + N(x1; μ = 7.00, σ² = 4.00))", text);
        }
开发者ID:accord-net,项目名称:framework,代码行数:27,代码来源:IndependentTest.cs

示例3: ConstructorTest5

 public void ConstructorTest5()
        {
            var normal = new NormalDistribution(mean: 4, stdDev: 4.2);

            double mean = normal.Mean;     // 4.0
            double median = normal.Median; // 4.0
            double var = normal.Variance;  // 17.64

            double cdf = normal.DistributionFunction(x: 1.4); // 0.26794249453351904
            double pdf = normal.ProbabilityDensityFunction(x: 1.4); // 0.078423391448155175
            double lpdf = normal.LogProbabilityDensityFunction(x: 1.4); // -2.5456330358182586

            double ccdf = normal.ComplementaryDistributionFunction(x: 1.4); // 0.732057505466481
            double icdf = normal.InverseDistributionFunction(p: cdf); // 1.4

            double hf = normal.HazardFunction(x: 1.4); // 0.10712736480747137
            double chf = normal.CumulativeHazardFunction(x: 1.4); // 0.31189620872601354

            string str = normal.ToString(CultureInfo.InvariantCulture); // N(x; μ = 4, σ² = 17.64)

            Assert.AreEqual(4.0, mean);
            Assert.AreEqual(4.0, median);
            Assert.AreEqual(17.64, var);
            Assert.AreEqual(0.31189620872601354, chf);
            Assert.AreEqual(0.26794249453351904, cdf);
            Assert.AreEqual(0.078423391448155175, pdf);
            Assert.AreEqual(-2.5456330358182586, lpdf);
            Assert.AreEqual(0.10712736480747137, hf);
            Assert.AreEqual(0.732057505466481, ccdf);
            Assert.AreEqual(1.4, icdf);
            Assert.AreEqual("N(x; μ = 4, σ² = 17.64)", str);
        }
开发者ID:qusma,项目名称:framework,代码行数:32,代码来源:NormalDistributionTest.cs

示例4: PinkNoise

 public PinkNoise(IRandomGenerator randomGenerator, float rmsAmplitude)
        {
            if (null == randomGenerator)
                throw new ArgumentNullException("randomGenerator");

            _whiteGenerator = new NormalDistribution(randomGenerator, 0, RmsScale * rmsAmplitude);
        }
开发者ID:henricj,项目名称:phonesm,代码行数:7,代码来源:PinkNoise.cs

示例5: ConstructorTest2

 public void ConstructorTest2()
        {
            var original =  new NormalDistribution(mean: 4, stdDev: 4.2);

            var normal = GeneralContinuousDistribution.FromDensityFunction(
                original.Support, original.ProbabilityDensityFunction);

            testNormal(normal);
        }
开发者ID:KommuSoft,项目名称:accord_framework,代码行数:9,代码来源:GeneralContinuousDistributionTest.cs

示例6: CreateModel1

 public static HiddenMarkovClassifier<Independent> CreateModel1()
        {
            // Create a Continuous density Hidden Markov Model Sequence Classifier
            // to detect a multivariate sequence and the same sequence backwards.
            double[][][] sequences = new double[][][]
            {
                new double[][] 
                { 
                    // This is the first  sequence with label = 0
                    new double[] { 0 },
                    new double[] { 1 },
                    new double[] { 2 },
                    new double[] { 3 },
                    new double[] { 4 },
                }, 

                new double[][]
                {
                     // This is the second sequence with label = 1
                    new double[] { 4 },
                    new double[] { 3 },
                    new double[] { 2 },
                    new double[] { 1 },
                    new double[] { 0 },
                }
            };

            // Labels for the sequences
            int[] labels = { 0, 1 };

            // Creates a sequence classifier containing 2 hidden Markov Models
            //  with 2 states and an underlying Normal distribution as density.
            NormalDistribution component = new NormalDistribution();
            Independent density = new Independent(component);
            var classifier = new HiddenMarkovClassifier<Independent>(2, new Ergodic(2), density);

            // Configure the learning algorithms to train the sequence classifier
            var teacher = new HiddenMarkovClassifierLearning<Independent>(classifier,

                // Train each model until the log-likelihood changes less than 0.001
                modelIndex => new BaumWelchLearning<Independent>(classifier.Models[modelIndex])
                {
                    Tolerance = 0.0001,
                    Iterations = 0
                }
            );

            // Train the sequence classifier using the algorithm
            double logLikelihood = teacher.Run(sequences, labels);

            Assert.AreEqual(-13.271981026832929d, logLikelihood);

            return classifier;
        }
开发者ID:CanerPatir,项目名称:framework,代码行数:54,代码来源:IndependentMarkovFunctionTest.cs

示例7: LearnTest1

 public void LearnTest1()
        {
            // Create a Continuous density Hidden Markov Model Sequence Classifier
            // to detect a univariate sequence and the same sequence backwards.
            double[][] sequences = new double[][] 
            {
                new double[] { 0,1,2,3,4 }, // This is the first  sequence with label = 0
                new double[] { 4,3,2,1,0 }, // This is the second sequence with label = 1
            };

            // Labels for the sequences
            int[] labels = { 0, 1 };

            // Creates a sequence classifier containing 2 hidden Markov Models
            //  with 2 states and an underlying Normal distribution as density.
            NormalDistribution density = new NormalDistribution();
            var classifier = new HiddenMarkovClassifier<NormalDistribution>(2, new Ergodic(2), density);

            // Configure the learning algorithms to train the sequence classifier
            var teacher = new HiddenMarkovClassifierLearning<NormalDistribution>(classifier,

                // Train each model until the log-likelihood changes less than 0.001
                modelIndex => new BaumWelchLearning<NormalDistribution>(classifier.Models[modelIndex])
                {
                    Tolerance = 0.0001,
                    Iterations = 0
                }
            );

            // Train the sequence classifier using the algorithm
            double logLikelihood = teacher.Run(sequences, labels);


            // Calculate the probability that the given
            //  sequences originated from the model
            double likelihood1, likelihood2;

            // Try to classify the first sequence (output should be 0)
            int c1 = classifier.Compute(sequences[0], out likelihood1);

            // Try to classify the second sequence (output should be 1)
            int c2 = classifier.Compute(sequences[1], out likelihood2);

            Assert.AreEqual(0, c1);
            Assert.AreEqual(1, c2);


            Assert.AreEqual(-13.271981026832929, logLikelihood, 1e-10);
            Assert.AreEqual(0.99999791320102149, likelihood1, 1e-10);
            Assert.AreEqual(0.99999791320102149, likelihood2, 1e-10);
            Assert.IsFalse(double.IsNaN(logLikelihood));
            Assert.IsFalse(double.IsNaN(likelihood1));
            Assert.IsFalse(double.IsNaN(likelihood2));
        }
开发者ID:qusma,项目名称:framework,代码行数:54,代码来源:HiddenMarkovClassifier`1Test.cs

示例8: ConstructorTest5

 public void ConstructorTest5()
        {
            var normal = new NormalDistribution(mean: 4, stdDev: 4.2);

            double mean = normal.Mean;     // 4.0
            double median = normal.Median; // 4.0
            double mode = normal.Mode;     // 4.0
            double var = normal.Variance;  // 17.64

            double cdf = normal.DistributionFunction(x: 1.4); // 0.26794249453351904
            double pdf = normal.ProbabilityDensityFunction(x: 1.4); // 0.078423391448155175
            double lpdf = normal.LogProbabilityDensityFunction(x: 1.4); // -2.5456330358182586

            double ccdf = normal.ComplementaryDistributionFunction(x: 1.4); // 0.732057505466481
            double icdf = normal.InverseDistributionFunction(p: cdf); // 1.4

            double hf = normal.HazardFunction(x: 1.4); // 0.10712736480747137
            double chf = normal.CumulativeHazardFunction(x: 1.4); // 0.31189620872601354

            string str = normal.ToString(CultureInfo.InvariantCulture); // N(x; μ = 4, σ² = 17.64)

            Assert.AreEqual(4.0, mean);
            Assert.AreEqual(4.0, median);
            Assert.AreEqual(4.0, mode);
            Assert.AreEqual(17.64, var);
            Assert.AreEqual(0.31189620872601354, chf);
            Assert.AreEqual(0.26794249453351904, cdf);
            Assert.AreEqual(0.078423391448155175, pdf);
            Assert.AreEqual(-2.5456330358182586, lpdf);
            Assert.AreEqual(0.10712736480747137, hf);
            Assert.AreEqual(0.732057505466481, ccdf);
            Assert.AreEqual(1.4, icdf);
            Assert.AreEqual("N(x; μ = 4, σ² = 17.64)", str);

            Assert.AreEqual(Accord.Math.Normal.Function(normal.ZScore(4.2)), normal.DistributionFunction(4.2));
            Assert.AreEqual(Accord.Math.Normal.Derivative(normal.ZScore(4.2)) / normal.StandardDeviation, normal.ProbabilityDensityFunction(4.2), 1e-16);
            Assert.AreEqual(Accord.Math.Normal.LogDerivative(normal.ZScore(4.2)) - Math.Log(normal.StandardDeviation), normal.LogProbabilityDensityFunction(4.2), 1e-15);

            var range1 = normal.GetRange(0.95);
            var range2 = normal.GetRange(0.99);
            var range3 = normal.GetRange(0.01);

            Assert.AreEqual(-2.9083852331961833, range1.Min);
            Assert.AreEqual(10.908385233196183, range1.Max);
            Assert.AreEqual(-5.7706610709715314, range2.Min);
            Assert.AreEqual(13.770661070971531, range2.Max);
            Assert.AreEqual(-5.7706610709715314, range3.Min);
            Assert.AreEqual(13.770661070971531, range3.Max);
        }
开发者ID:CanerPatir,项目名称:framework,代码行数:49,代码来源:NormalDistributionTest.cs

示例9: ByParams

 public static NormalDistribution ByParams(double expectation, double variance)
    {
        if (Double.IsInfinity(expectation) || Double.IsNaN(expectation))
                throw new ArgumentException("The expectation must be a finite number");

            if (variance <= 0 || Double.IsInfinity(expectation) || Double.IsNaN(expectation))
                throw new ArgumentException("The variance must be a positive finite number");

            NormalDistribution distribution = new NormalDistribution();
            distribution.Expectation = expectation;
            distribution.Variance = variance;

            distribution.ComputeInternalParameters();

            return distribution;
    }
开发者ID:samuto,项目名称:designscript,代码行数:16,代码来源:NormalDistribution.cs

示例10: NormalGenerateTest

 public void NormalGenerateTest()
        {
            // Create a Normal with mean 2 and sigma 5
            var normal = new NormalDistribution(2, 5);

            // Generate 1000000 samples from it
            double[] samples = normal.Generate(1000000);

            // Try to estimate a new Normal distribution from the 
            // generated samples to check if they indeed match
            var actual = NormalDistribution.Estimate(samples);

            string result = actual.ToString("N2"); // N(x; μ = 2.01, σ² = 25.03)

            Assert.AreEqual("N(x; μ = 2.01, σ² = 25.03)", result);
        }
开发者ID:amurshed,项目名称:statistics-workbench,代码行数:16,代码来源:ArticleExamplesTest.cs

示例11: Start

 // Use this for initialization
    void Start()
    {
        // Save a pointer to the fusion engine
        fusionEngine = GetComponentInParent<FusionEngine>();

        // Get a pointer to the target
        targets = GameObject.FindGameObjectsWithTag("Target");

        // Noise distribution
        nd = new NormalDistribution(0, 1);
        noiseCovariance = new Matrix(3, 3);
        noiseCovariance[0, 0] = 1e-3;
        noiseCovariance[1, 1] = 1e-3;
        noiseCovariance[2, 2] = 1e-3;

        noiseCovCholT = noiseCovariance.CholeskyDecomposition.TriangularFactor.Clone();
        noiseCovCholT.Transpose();

        // Reset time since the last update
        timeSinceLastUpdateSec = 0.0f;
    }
开发者ID:philiptwu,项目名称:fusion-engine,代码行数:22,代码来源:MeasurementGenerator.cs

示例12: ConstructorTest1

 public void ConstructorTest1()
        {

            NormalDistribution normal = new NormalDistribution(4.2, 1.2);
            MultivariateNormalDistribution target = new MultivariateNormalDistribution(new[] { 4.2 }, new[,] { { 1.2 * 1.2 } });

            double[] mean = target.Mean;
            double[] median = target.Median;
            double[] var = target.Variance;
            double[,] cov = target.Covariance;

            double apdf1 = target.ProbabilityDensityFunction(new double[] { 2 });
            double apdf2 = target.ProbabilityDensityFunction(new double[] { 4 });
            double apdf3 = target.ProbabilityDensityFunction(new double[] { 3 });
            double alpdf = target.LogProbabilityDensityFunction(new double[] { 3 });
            double acdf = target.DistributionFunction(new double[] { 3 });
            double accdf = target.ComplementaryDistributionFunction(new double[] { 3 });

            double epdf1 = target.ProbabilityDensityFunction(new double[] { 2 });
            double epdf2 = target.ProbabilityDensityFunction(new double[] { 4 });
            double epdf3 = target.ProbabilityDensityFunction(new double[] { 3 });
            double elpdf = target.LogProbabilityDensityFunction(new double[] { 3 });
            double ecdf = target.DistributionFunction(new double[] { 3 });
            double eccdf = target.ComplementaryDistributionFunction(new double[] { 3 });


            Assert.AreEqual(normal.Mean, target.Mean[0]);
            Assert.AreEqual(normal.Median, target.Median[0]);
            Assert.AreEqual(normal.Variance, target.Variance[0]);
            Assert.AreEqual(normal.Variance, target.Covariance[0, 0]);

            Assert.AreEqual(epdf1, apdf1);
            Assert.AreEqual(epdf2, apdf2);
            Assert.AreEqual(epdf3, apdf3);
            Assert.AreEqual(elpdf, alpdf);
            Assert.AreEqual(ecdf, acdf);
            Assert.AreEqual(eccdf, accdf);
            Assert.AreEqual(1.0 - ecdf, eccdf);
        }
开发者ID:KommuSoft,项目名称:accord_framework,代码行数:39,代码来源:MultivariateNormalDistributionTest.cs

示例13: Combat

 public Combat(Unit attacker, Unit defender, bool useRandomisedCombatEfficiency, List<Unit> antiAirUnits = null)
        {
            UseRandomisedCombatEfficiency = useRandomisedCombatEfficiency;
            Generator = new NormalDistribution(GameConstants.CombatEfficiencyMean, GameConstants.CombatEfficiencyDeviation);

            Attacker = new UnitCombatState(attacker, this);
            Defender = new UnitCombatState(defender, this);

            if (attacker.IsAirUnit())
            {
                AttackType = AttackType.AirAttack;
                AntiAirUnits = antiAirUnits.Select((Unit x) => new UnitCombatState(x, this)).ToList();
                foreach (var unit in AntiAirUnits)
                    unit.SetDamage(unit.Unit.Type.Stats.AirAttack.Value);
            }
            else if (attacker.IsArtillery())
                AttackType = AttackType.ArtilleryAttack;
            else
                AttackType = AttackType.GroundAttack;

            // Calculate the outcome right away
            Attack();
        }
开发者ID:epicvrvs,项目名称:PanzerKontrol,代码行数:23,代码来源:Combat.cs

示例14: ConstructorTest

 public void ConstructorTest()
        {
            var p1 = new NormalDistribution(4.2, 1);
            var p2 = new NormalDistribution(7.0, 2);

            Independent<NormalDistribution> target = new Independent<NormalDistribution>(p1, p2);

            Assert.AreEqual(target.Components[0], p1);
            Assert.AreEqual(target.Components[1], p2);

            Assert.AreEqual(2, target.Dimension);

            Assert.AreEqual(4.2, target.Mean[0]);
            Assert.AreEqual(7.0, target.Mean[1]);

            Assert.AreEqual(1, target.Variance[0]);
            Assert.AreEqual(4, target.Variance[1]);

            Assert.AreEqual(1, target.Covariance[0, 0]);
            Assert.AreEqual(4, target.Covariance[1, 1]);
            Assert.AreEqual(0, target.Covariance[0, 1]);
            Assert.AreEqual(0, target.Covariance[1, 0]);
        }
开发者ID:RLaumeyer,项目名称:framework,代码行数:23,代码来源:IndependentTest.cs

示例15: MedianTest

 public void MedianTest()
        {
            NormalDistribution target = new NormalDistribution(0.4, 2.2);

            Assert.AreEqual(target.Median, target.InverseDistributionFunction(0.5));
        }
开发者ID:qusma,项目名称:framework,代码行数:6,代码来源:NormalDistributionTest.cs

本文标签属性:

示例:示例是什么意思

代码:代码转换器

NormalDistribution:NormalDistribution

上一篇:PHP RSSFeed::buildRSS方法代码示例(phprssfeed::buildrss方法的典型用法代码示例)
下一篇:流失的读音流失的读音是什么(流失是什么意思啊)

为您推荐