Wpf/Histogram/DataProvider.cs

(完整代码) 733B

using System;
using System.Collections.Generic;

namespace Geared.Wpf.Histogram
{
    public static class DataProvider
    {
        public static IEnumerable<double> GetNormalDistribution(double variance, double expectation, int ticks)
        {
            var teoricalVariance = 3 * variance;
            var step = (expectation + teoricalVariance - (expectation - teoricalVariance)) / ticks;

            for (var x = expectation-teoricalVariance; x <= expectation + teoricalVariance; x += step)
            {
                yield return
                    (1 / (variance * Math.Pow(2 * Math.PI, -2))) *
                    Math.Pow(Math.E, -0.5 * Math.Pow((x - expectation) / variance, 2));
            }
        }
    }
}

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。