Fitting the Weibull Distribution

The Weibull distribution is widely used in reliability analysis, hazard analysis, for modeling part failure rates and in many other applications. The NMath library currently includes 19 probably distributions and has recently added a fitting function to the Weibull distribution class at the request of a customer.

The Weibull probability distribution, over the random variable x, has two parameters:

  • k > 0, is the shape parameter
  • λ > 0, is the scale parameter

Frequently engineers have data that is known to be well modeled by the Weibull distribution but the shape and scale parameters are unknown. In this case a data fitting strategy can be used; NMath now has a maximum likelihood Weibull fitting function demonstrated in the code example below.

    public void WiebullFit()
      double[] t = new double[] { 16, 34, 53, 75, 93, 120 };
      double initialShape = 2.2;
      double initialScale = 50.0;

      WeibullDistribution fittedDist = WeibullDistribution.Fit( t, initialScale, initialShape );

      // fittedDist.Shape parameter will equal 1.933
      // fittedDist.Scale parameter will equal 73.526

If the Weibull fitting algorithm fails the returned distribution will be null. In this case improving the initial parameter guesses can help. The WeibullDistribution.Fit() function accepts either arrays, as seen above, or DoubleVectors.

The latest version of NMath, including this maximum likelihood Weibull fit function, is available on the CenterSpace NuGet gallery.

Leave a Reply

Your email address will not be published. Required fields are marked *