weibull_inverse_cdf

Evaluates the Weibull inverse cumulative distribution function (quantile function).

Synopsis

#include <imsls.h>

float imsls_f_weibull_inverse_cdf (float p, float k, float lambda)

The type double function is imsls_d_weibull_inverse_cdf.

Required Arguments

float p (Input)
Probability for which the corresponding quantile from the Weibull distribution is to be computed. This must be in the range [0, 1].

float k (Input)
Shape parameter of the Weibull distribution. This parameter must be positive (k > 0).

float lambda (Input)
Scale parameter of the Weibull distribution. This parameter must be positive (λ > 0).

Return Value

The quantile (x-value) such that the probability of a Weibull random variable being less than or equal to that value equals p. The function returns NaN if any parameter is NaN, if k ≤ 0, lambda ≤ 0, or if p is outside [0, 1]. Returns 0.0 for p = 0.0 and positive infinity for p = 1.0.

Description

Function imsls_f_weibull_inverse_cdf evaluates the inverse cumulative distribution function (quantile function), F-1, of a Weibull random variable with shape parameter k and scale parameter lambda.

The inverse cumulative distribution function of the Weibull distribution is:

for 0 ≤ p ≤ 1, where:

  • k > 0 is the shape parameter

  • λ > 0 is the scale parameter

  • p is the probability (cumulative probability)

Example

This example evaluates the Weibull PDF, CDF, and inverse CDF for array of x-values. Note that the inverse CDF is infinite for p= 1.0.

Copy
#include "imsls_i.h"

int main() 
{
    int i;

    float k = 5.0, lambda = 1.0;
    float x[] = { 0.0, 0.25, 0.5, 0.75, 1.0, 5.0, 10.0 };
    float pdf, cdf, quantile;
 
    printf("Weibull PDF, CDF, and Inverse CDF document example\n");
    printf("Shape parameter k =    %4.1f\n", k);
    printf("Scale parameter lambda = %4.1f\n", lambda);
    printf("        x         pdf          cdf       quantile \n");
    
    for (i = 0; i < 7; i++) {
        pdf = imsls_f_weibull_pdf(x[i], k, lambda);
        cdf = imsls_f_weibull_cdf(x[i], k, lambda);
        quantile = imsls_f_weibull_inverse_cdf(cdf, k, lambda);
    
        printf(" %10.4f %12.8f %12.8f %10.4f\n", x[i], pdf, cdf, quantile);    
   }
}

Output

Copy
Acceptance Test for (SP) weibull pdf, cdf, inverse cdf

Weibull  PDF, CDF, and Inverse CDF document example
Shape parameter k =     5.0
Scale parameter lambda =  1.0
        x         pdf          cdf       quantile
     0.0000   0.00000000   0.00000000     0.0000
     0.2500   0.01951219   0.00097609     0.2500
     0.5000   0.30288538   0.03076676     0.5000
     0.7500   1.24782860   0.21124907     0.7500
     1.0000   1.83939719   0.63212055     1.0000

*** WARNING  Error IMSLS_P_ZERO_OR_ONE from imsls_f_weibull_inverse_cdf.
***          The probability "p" = 1.000000e+00. The function returns machine
***          infinity.

     5.0000   0.00000000   1.00000000        inf

*** WARNING  Error IMSLS_P_ZERO_OR_ONE from imsls_f_weibull_inverse_cdf.
***          The probability "p" = 1.000000e+00. The function returns machine
***          infinity.

    10.0000   0.00000000   1.00000000        inf

Warning Errors

IMSLS_P_ZERO_OR_ONE

The argument "p" is 1.0. The function returns machine infinity.

Fatal Errors

IMSLS_BAD_ARGS_1

The arguments "x" = #,"k" = #, "lambda" = # result in NaN's (not a number) in the calculations. The function returns NaN.