Пример #1
0
 /// Create an instance of the receiver with parameters estimated from
 /// the given histogram using best guesses. This method can be used to
 /// find the initial values for a fit.
 /// @param h DhbScientificCurves.Histogram
 /// @exception ArgumentOutOfRangeException
 ///							when no suitable parameter can be found.
 public WeibullDistribution(Histogram h)
 {
     if (h.Minimum < 0)
         throw new ArgumentOutOfRangeException(
                 "Weibull distribution is only defined for non-negative values");
     double average = h.Average;
     if (average <= 0)
         throw new ArgumentOutOfRangeException(
                 "Weibull distribution must have a non-negative average");
     double xMin = (h.Minimum + average) * 0.5;
     double accMin = System.Math.Log(-System.Math.Log(1 - h.CountsUpTo(xMin) / h.TotalCount));
     double xMax = (h.Maximum + average) * 0.5;
     double accMax = System.Math.Log(-System.Math.Log(1 - h.CountsUpTo(xMax) / h.TotalCount));
     double delta = accMax - accMin;
     xMin = System.Math.Log(xMin);
     xMax = System.Math.Log(xMax);
     DefineParameters(delta / (xMax - xMin),
                         System.Math.Exp((accMax * xMin - accMin * xMax) / delta));
 }