Accord.Statistics.Distributions.Univariate.NormalDistribution.Fit C# (CSharp) Method

Fit() public method

Fits the underlying distribution to a given set of observations.
public Fit ( double observations, double weights ) : IDistribution
observations double /// The array of observations to fit the model against. ///
weights double /// The weight vector containing the weight for each of the samples. ///
return IDistribution
        public override IDistribution Fit(double[] observations, double[] weights)
        {
            // Compute weighted mean
            double mean = observations.Mean(weights);

            // Compute weighted variance
            double variance = Tools.Variance(observations, mean, weights);

            return new NormalDistribution(mean, variance);
        }

Usage Example

コード例 #1
0
        /// <summary>
        ///   Estimates a new Normal distribution from a given set of observations.
        /// </summary>
        ///
        public static NormalDistribution Estimate(double[] observations, double[] weights, NormalOptions options)
        {
            NormalDistribution n = new NormalDistribution();

            n.Fit(observations, weights, options);
            return(n);
        }
All Usage Examples Of Accord.Statistics.Distributions.Univariate.NormalDistribution::Fit