![]() |
Home | Libraries | People | FAQ | More |
#include <boost/math/distributions/cauchy.hpp>
template <class RealType = double, class Policy = policies::policy<> > class cauchy_distribution; typedef cauchy_distribution<> cauchy; template <class RealType, class Policy> class cauchy_distribution { public: typedef RealType value_type; typedef Policy policy_type; cauchy_distribution(RealType location = 0, RealType scale = 1); RealType location()const; RealType scale()const; };
柯西-洛倫茨分佈(Cauchy-Lorentz distribution) 以 Augustin Cauchy 和 Hendrik Lorentz命名。 它是一個連續概率分佈(continuous probability distribution) ,概率分佈函數(probability distribution function) PDF 由下面的等式給定:
位置參數(location parameter) x0 是分佈的峰值(peak)的位置(分佈的眾數( mode of the distribution)),而尺度參數(scale parameter) γ 指定PDF函數在1/2最大高度處的1/2寬度。如果位置是0,且尺度(scale)是1,那麼結果就是標準的柯西分佈(standard Cauchy distribution)。
在物理學中這個分佈很重要,因為它是描述受力共振的微分方程(differential equation describing forced resonance)的解,而在光譜學(spectroscopy)中,它描述譜線(spectral lines)的線條形狀(line shape)。
下面的圖像顯示了當位置參數改變時,分佈的圖像是如何改變的:
而下面的圖像顯示了尺度參數(scale parameter)是如何影響分佈的:
cauchy_distribution(RealType location = 0, RealType scale = 1);
使用位置參數(location parameter) location 和尺度參數(scale parameter) scale 構造一個柯西分佈。當這些參數使用缺省值時,結果是一個標準柯西分佈。
要求 scale > 0, 否則調用 定義域錯誤。
RealType location()const;
返回分佈的位置參數( location parameter)。
RealType scale()const;
返回分佈的尺度參數(scale parameter)。
支持所有的分佈都通用的 常見的非成員訪問函數 : 累積分佈函數(Cumulative Distribution Function),概率密度函數(Probability Density Function),分位點(Quantile), 故障率函數(Hazard Function), 累積危險函數(Cumulative Hazard Function), 均值(mean), 中位數(median), 眾數(mode), 方差(variance), 標準差(standard deviation), 偏斜(skewness), 峰態(kurtosis), 峰態超越(kurtosis_excess), 值域(range) 以及 支持(support)。
注意:實際上柯西分佈沒有均值(mean),標準差(standard deviation),等等。參考數學上的未定義函數 。
為了控制這是否將會產生錯誤,使用BOOST_STATIC_ASSERTION_FAILURE來編譯,這也是缺省的設置。.
另一方面,如果調用了這些函數均值(mean),標準差(standard deviation),方差(variance),偏斜(skewness),峰態(kurtosis) 以及 峰態超越(kurtosis_excess) 將會返回一個定義域錯誤 。
隨機變量的定義域是 [-[max_value], +[min_value]].
柯西分佈使用標準庫函數tan 和 atan ,並且只會有很低的誤差率。
在下面的表中, x0 是位置參數( location parameter),γ 是尺度參數( scale parameter),x 是隨機變量,p 是概率,且 q = 1-p。
|
函數 |
實現註解 |
|---|---|
|
|
使用關係:pdf = 1 / (π * γ * (1 + ((x - x0 ) / γ)2) |
|
cdf and its complement |
函數cdf通常由下面的等式給定: p = 0.5 + atan(x)/π
但是隨著 x -> -∞,這會產生消去錯誤( cancellation error )。對於 atan(x) = -π/2 - atan(1/x) 代入上面的等式我們可以得到: p = -atan(1/x) ; x < 0 因此計算過程就是使用上面的方程針對 -fabs(x) 計算函數cdf 。注意:對於位置( location) 和尺度( scale)參數,你必須使用 (x - x0 ) / γ 替換 x 代入上面等式中。 這個過程產生較小的p 和 q, 依據我們是否想要獲得補集來決定是否用1減去這個結果。 |
|
quantile |
我們仍然使用這個計算過程而不需要考慮我們是從這個概率開始還是從它的補集開始。首先參數p簡化到區間 [-0.5, 0.5],然後使用關係: x = x0 ?γ / tan(π * p) 來獲取結果。依據我們是否從補集開始來決定我們是否要用 x0 減去結果。 |
|
mode |
位置參數(location parameter)。 |