weibull_pdf
Evaluates the Weibull probability density function (PDF).
Synopsis
#include <imsls.h>
float imsls_f_weibull_pdf (float x, float k, float lambda)
The type double function is imsls_d_weibull_pdf.
Required Arguments
float x (Input)
Argument for which the Weibull probability density function is to be evaluated.
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 probability density at x for a Weibull random variable with the specified parameters. The function returns NaN if any parameter is NaN or if k ≤ 0 or lambda ≤ 0. Returns 0.0 for x < 0.
Description
Function imsls_f_weibull_pdf evaluates the probability density function, f, of a Weibull random variable with shape parameter k and scale parameter lambda.
The probability density function of the Weibull distribution is:
where:
-
k > 0 is the shape parameter that determines the shape of the distribution
-
λ > 0 is the scale parameter that stretches or compresses the distribution
Example
This example evaluates the Weibull PDF, CDF, and inverse CDF for an array of x-values. Note that the inverse CDF is infinite for p = 1.0.
#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
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. |
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. |