weibull_cdf

Evaluates the Weibull cumulative distribution function (CDF).

Synopsis

#include <imsls.h>

float imsls_f_weibull_cdf (float x, float k, float lambda)

The type double function is imsls_d_weibull_cdf.

Required Arguments

float x (Input)
Argument for which the Weibull distribution function is to be evaluated.

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

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

Return Value

The probability that a Weibull random variable takes a value less than or equal to x. The function returns NaN if any parameter is NaN or if k ≤ 0 or lambda ≤ 0.

Description

Function imsls_f_weibull_cdf evaluates the distribution function, F, of a weibull random variable with shape parameter k, and scale parameter lambda.

The value of the distribution function at the point x is the probability that the random variable takes a value less than or equal to x.

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_INFINITE_ARG

The argument "x" is infinite. The function returns 1.0.