({{, (RefLink[HazardFunction, paclet:ref/HazardFunction])[dist,x] 
gives the hazard function for the distribution dist evaluated at x.}, {, (RefLink[HazardFunction, paclet:ref/HazardFunction])[dist,{(Subscript[x, 1]),(Subscript[x, 2]),…}]
gives the multivariate hazard function for the distribution dist evaluated at {(Subscript[x, 1]),(Subscript[x, 2]),…}.}, {, (RefLink[HazardFunction, paclet:ref/HazardFunction])[dist]
gives the hazard function as a pure function.}})

OpenersNotesSection(Spacer1)Details

(RefLink[HazardFunction, paclet:ref/HazardFunction]) is also known as a force of mortality.

For continuous distributions, (RefLink[HazardFunction, paclet:ref/HazardFunction])[dist,x] dx gives the probability that an observed value lies between x and x+dx, given that it is larger than x for infinitesimal dx.

For continuous distributions, (RefLink[HazardFunction, paclet:ref/HazardFunction])[dist,x] dx is equivalent to (RefLink[Probability, paclet:ref/Probability])[x≤ξ<x+dx\[Conditioned]ξ≥x,ξ\[Distributed]dist] for infinitesimal dx. »

For discrete distributions, (RefLink[HazardFunction, paclet:ref/HazardFunction])[dist,x] is equivalent to (RefLink[Probability, paclet:ref/Probability])[ξ==x\[Conditioned]ξ≥x,ξ\[Distributed]dist].

For continuous multivariate distributions, (RefLink[HazardFunction, paclet:ref/HazardFunction])[dist,{(Subscript[x, 1]),…,(Subscript[x, n])}](Subscript[dx, 1]) ⋯ (Subscript[dx, n]) is equivalent to (RefLink[Probability, paclet:ref/Probability])[(Subscript[x, 1])≤(Subscript[ξ, 1])<(Subscript[x, 1])+(Subscript[dx, 1])∧⋯∧(Subscript[x, n])≤(Subscript[ξ, n])<(Subscript[x, n])+(Subscript[dx, n])\[Conditioned](Subscript[ξ, 1])≥(Subscript[x, 1])∧⋯∧(Subscript[ξ, n])≥(Subscript[x, n]),{(Subscript[ξ, 1]),…,(Subscript[ξ, n])}\[Distributed]dist].

For discrete multivariate distributions, (RefLink[HazardFunction, paclet:ref/HazardFunction])[dist,{(Subscript[x, 1]),…,(Subscript[x, n])}] is equivalent to (RefLink[Probability, paclet:ref/Probability])[(Subscript[ξ, 1])==(Subscript[x, 1])∧⋯ ∧(Subscript[ξ, n])==(Subscript[x, n])\[Conditioned](Subscript[ξ, 1])≥(Subscript[x, 1])∧⋯∧(Subscript[ξ, n])≥(Subscript[x, n]),{(Subscript[ξ, 1]),…,(Subscript[ξ, n])}\[Distributed]dist].

OpenersPrimaryExamplesSection(Spacer1)Examples  (34)

OpenersExampleSection0(Spacer1)Basic Examples  (4)

A hazard function for a continuous univariate distribution:

HazardFunction[WeibullDistribution[1/2,2],x]

Plot[%,{x,0,3},Filling->Axis]

The hazard function for a discrete univariate distribution:

HazardFunction[PoissonDistribution[2],x]

DiscretePlot[%,{x,0,20},ExtentSize->0.5]

A hazard function for a continuous multivariate distribution:

Plot3D[HazardFunction[BinormalDistribution[1/2],{x,y}],{x,-1,3},{y,-1,3},PlotRange->All,MaxRecursion->0]

A hazard function for a discrete multivariate distribution:

DiscretePlot3D[HazardFunction[MultivariatePoissonDistribution[1,{2,3}],{x,y}],{x,0,20},{y,0,20},ExtentSize->0.5]

OpenersExampleSection1(Spacer1)Scope  (20)

OpenersExampleSubsection0(Spacer1)Parametric Distributions  (6)

Obtain exact numeric results:

HazardFunction[WeibullDistribution[2,5],4]

HazardFunction[NegativeBinomialDistribution[20,1/3],5]

Obtain a machine-precision result:

HazardFunction[WeibullDistribution[2,5],4.]

Obtain a result at any precision for a continuous distribution:

HazardFunction[WeibullDistribution[2,5],N[4,25]]

Obtain a result at any precision for a discrete distribution with inexact parameters:

HazardFunction[NegativeBinomialDistribution[20,N[1/3,30]],1]

Hazard function for a multivariate distribution:

HazardFunction[DirichletDistribution[{2,4,5}],{1/5,2/3}]

Obtain a symbolic expression for the hazard function:

HazardFunction[ChiSquareDistribution[ν],x]

HazardFunction[UniformDistribution[{{a,b},{c,d}}],{x,y}]

OpenersExampleSubsection1(Spacer1)Nonparametric Distributions  (3)

Hazard function for nonparametric distributions:

r=RandomVariate[NormalDistribution[],10^4];

HazardFunction[HistogramDistribution[r],0.2]

HazardFunction[SmoothKernelDistribution[r],0.2]

HazardFunction[KernelMixtureDistribution[r],0.2]

Compare with the value for the underlying parametric distribution:

HazardFunction[NormalDistribution[],0.2]

Plot the survival function for a histogram distribution:

dist=HistogramDistribution[RandomVariate[NormalDistribution[],10^3]];

Plot[HazardFunction[dist,x]//Evaluate,{x,-3,3},Filling->Axis,Exclusions->None]

Plot of the survival function of a bivariate smooth kernel distribution:

dist=SmoothKernelDistribution[RandomVariate[BinormalDistribution[1/3],30]];

Plot3D[HazardFunction[dist,{x,y}]//Evaluate,{x,-4,4},{y,-4,4},PlotRange->All]

OpenersExampleSubsection2(Spacer1)Derived Distributions  (8)

Product of independent distributions:

hf=HazardFunction[ProductDistribution[TriangularDistribution[{2,4}],TriangularDistribution[{1,7}]],{x,y}]

Plot3D[hf,{x,1,5},{y,0,8},PlotRange->{0,100}]

Component mixture distribution:

hf=HazardFunction[MixtureDistribution[{1,4},{NormalDistribution[a,b],NormalDistribution[c,d]}],x]

Plot[hf/.{a-> 0,b->1,c->6,d-> 3/2},{x,-2,6},Filling-> Axis]

Quadratic transformation of a discrete distribution:

HazardFunction[TransformedDistribution[x^2,x\[Distributed]ExponentialDistribution[2]],y]

Plot[%,{y,0,8},Filling->Axis,AxesOrigin->{0,0}]

Truncated distribution:

hf=HazardFunction[TruncatedDistribution[{2,3},TriangularDistribution[{1,4}]],x]

Plot[hf,{x,1.5,5},Filling->Axis]

A copula distribution:

HazardFunction[CopulaDistribution[{"AMH",1/3},{UniformDistribution[{2,4}],UniformDistribution[{3,7}]}],{x,y}]//Simplify

Formula distributions defined by its PDF:

HazardFunction[ProbabilityDistribution[UnitBox[x],{x,-Infinity,Infinity}],x]//FullSimplify

Defined by its CDF:

HazardFunction[ProbabilityDistribution[{"CDF",Piecewise[{{-2+x,2≤x≤3},{1,x>3}},0]},{x,-Infinity,Infinity}],x]

Defined by its survival function:

HazardFunction[ProbabilityDistribution[{"SF",Piecewise[{{1-2(-2+x)^2,2≤x≤5/2},{2(3-x)^2,5/2<x≤ 3},{1,x<2}},0]},{x,-Infinity,Infinity}],x]

Marginal distribution:

HazardFunction[MarginalDistribution[
ProbabilityDistribution[1/(E^(y^2/2)(Pi^(3/2)*(1 + x^4))), 
    {x, -Infinity, Infinity}, {y, -Infinity, Infinity}], 2], y]

Hazard function for (RefLink[QuantityDistribution, paclet:ref/QuantityDistribution]) assumes the argument is a (RefLink[Quantity, paclet:ref/Quantity]) with compatible units:

𝒟=NormalDistribution[Quantity[4,"Meters"],Quantity[1/2,"Meters"]]

HazardFunction[𝒟,x]

This allows for direct quantity substitution:

%/.x->Quantity[387.,"Centimeters"]

Compare with direct use of quantity argument:

HazardFunction[𝒟,Quantity[387.,"Centimeters"]]

OpenersExampleSubsection3(Spacer1)Random Processes  (3)

Find the hazard function for a (RefLink[SliceDistribution, paclet:ref/SliceDistribution]) of a discrete-state random process:

HazardFunction[PoissonProcess[μ][2],x]

DiscretePlot[Evaluate[%/.μ->2],{x,0,10},ExtentSize->0.5]

A continuous-state random process:

HazardFunction[WienerProcess[][2],x]

Plot[%,{x,-1,6},Filling->Axis]

Find the multiple time-slice hazard function for a discrete-state process:

HazardFunction[PoissonProcess[μ][{2,3}],{1,2}]

DiscretePlot3D[Evaluate[HazardFunction[PoissonProcess[1][{2,3}],{x,y}]],{x,0,10},{y,0,10},ExtentSize->0.5]

A multi-slice for a continuous-state process:

Plot3D[HazardFunction[WienerProcess[][{2,3}],{x,y}],{x,-3,3},{y,-3,3},PlotRange->All]

Hazard function for the (RefLink[StationaryDistribution, paclet:ref/StationaryDistribution]) of a discrete-state random process:

HazardFunction[StationaryDistribution[QueueingProcess[λ,μ,Infinity]],x]//FullSimplify

DiscretePlot[Evaluate[%/.{μ->7,λ->2.9}],{x,1,8},ExtentSize->0.5]

OpenersExampleSection2(Spacer1)Generalizations & Extensions  (1)

(RefLink[HazardFunction, paclet:ref/HazardFunction]) threads element-wise over lists:

HazardFunction[NormalDistribution[],{0.2,0.3}]

{HazardFunction[NormalDistribution[],0.2],HazardFunction[NormalDistribution[],0.3]}

Multivariate distributions:

HazardFunction[BinormalDistribution[1/2],{{0.0,0.0},{0.2,0.2},{0.3,0.3}}]

OpenersExampleSection3(Spacer1)Applications  (4)

Find the mortality rate for lifetime distributions including exponential distribution:

Refine[HazardFunction[ExponentialDistribution[λ],x],x≥0]

Gompertz distribution:

HazardFunction[GompertzMakehamDistribution[λ,ξ],x]

Given the reliability function of a component, compute its failure rate:

R[t_]=Exp[-t^2];

Define the corresponding probability distribution:

𝒟=ProbabilityDistribution[{"SF",R[t]},{t,0,∞}];

Compute the failure rate using the distribution:

FailureRate=HazardFunction[𝒟,t]

Study the hazard function for a family of Weibull distributions:

w[α_,1]:=WeibullDistribution[α,1]

hf[α_,x_]=HazardFunction[w[α,1],x]

With α<1, used is better than new:

Plot[Table[hf[α,x],{α,{0.2,0.3,0.7}}]//Evaluate,{x,0,3}]

With α=1, used is as good as new:

Plot[hf[1,x],{x,0,3}]

With α>1, used is worse than new:

Plot[Table[hf[α,x],{α,{1.6,2.3,3.1}}]//Evaluate,{x,0,2}]

A casino offers you a game where you pay amount P to participate and then choose a stake amount c. A positive continuous random variable x following a known distribution 𝒟 is then generated. If x>c you collect the stake; otherwise you lose. Find the value c that maximizes the profit:

ExpectedGain=c SurvivalFunction[𝒟,c]-P;

Find the equation for the maximum of the expected gain:

D[ExpectedGain,c]==0/.{D[SurvivalFunction[𝒟,c],c]->-SurvivalFunction[𝒟,c] HazardFunction[𝒟,c]}

eq=Simplify[%,SurvivalFunction[𝒟,c]>0]

Assuming (RefLink[WeibullDistribution, paclet:ref/WeibullDistribution]), find the optimal stake size:

Solve[(eq/.𝒟->WeibullDistribution[α,β]),c,Reals]

ExpectedGain/.𝒟->WeibullDistribution[α,β]/.%//Simplify

OpenersExampleSection4(Spacer1)Properties & Relations  (3)

Compute the hazard function using the definition as conditional probability:

Probability[x≤ξ<x+dx\[Conditioned]ξ≥x,ξ\[Distributed]ExponentialDistribution[λ]]/dx

Limit[%,dx->0,Assumptions->λ>0&&x>0]

The hazard function is a ratio of the PDF and the survival function h(x)=f(x)/S(x):

HazardFunction[NormalDistribution[],x]

PDF[NormalDistribution[],x]/SurvivalFunction[NormalDistribution[],x]

The hazard rate of an exponential distribution is constant:

Refine[HazardFunction[ExponentialDistribution[λ],x],x≥0]

OpenersExampleSection5(Spacer1)Possible Issues  (2)

Symbolic closed forms do not exist for some distributions:

HazardFunction[StableDistribution[0,1.8,-0.5,1,2],x]

Numerical evaluation works:

HazardFunction[StableDistribution[0,1.8,-0.5,1,2],0.3]

Substitution of invalid values into symbolic outputs gives results that are not meaningful:

HazardFunction[CauchyDistribution[2,3],y]/.{y->1.+I}

Passing it as an argument, it stays unevaluated:

HazardFunction[CauchyDistribution[2,3],1.+I]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[PDF, paclet:ref/PDF])  ▪  (RefLink[SurvivalFunction, paclet:ref/SurvivalFunction])  ▪  (RefLink[CDF, paclet:ref/CDF])  ▪  (RefLink[Probability, paclet:ref/Probability])  ▪  (RefLink[NProbability, paclet:ref/NProbability])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Reliability, paclet:guide/Reliability])}, {▪(RefLinkPlain[Statistical Distribution Functions, paclet:guide/StatisticalDistributionFunctions])}, {▪(RefLinkPlain[Random Variables, paclet:guide/RandomVariables])}})}})