Boost C++ 库

...世界上最受推崇和专业设计的 C++ 库项目之一。 Herb SutterAndrei Alexandrescu, C++ 编码标准

PrevUpHomeNext

超指数分布

#include <boost/math/distributions/hyperexponential.hpp>
namespace boost{ namespace math{

template <typename RealType = double,
          typename Policy   = policies::policy<> >
class hyperexponential_distribution;

typedef hyperexponential_distribution<> hyperexponential;

template <typename RealType, typename Policy>
class hyperexponential_distribution
{
public:
   typedef RealType value_type;
   typedef Policy   policy_type;

   // Constructors:
   hyperexponential_distribution();  // Default.

   template <typename RateIterT, typename RateIterT2>
   hyperexponential_distribution(  // Default equal probabilities.
                                 RateIterT const& rate_first,
                                 RateIterT2 const& rate_last);  // Rates using Iterators.

   template <typename ProbIterT, typename RateIterT>
   hyperexponential_distribution(ProbIterT prob_first, ProbIterT prob_last,
                                 RateIterT rate_first, RateIterT rate_last);   // Iterators.

   template <typename ProbRangeT, typename RateRangeT>
   hyperexponential_distribution(ProbRangeT const& prob_range,
                                 RateRangeT const& rate_range);  // Ranges.

   template <typename RateRangeT>
   hyperexponential_distribution(RateRangeT const& rate_range);

 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)     // C++11 initializer lists supported.
   hyperexponential_distribution(std::initializer_list<RealType> l1, std::initializer_list<RealType> l2);
   hyperexponential_distribution(std::initializer_list<RealType> l1);
 #endif

   // Accessors:
   std::size_t num_phases() const;
   std::vector<RealType> probabilities() const;
   std::vector<RealType> rates() const;
};

}} // namespaces
[Note] 注意

提供了一种实现定义的机制,以避免接受范围、迭代器和常量作为参数的构造函数之间产生歧义。 这对用户应该是透明的。 请参阅下文和头文件 hyperexponential.hpp 以获取详细信息和解释性注释。

类类型 hyperexponential_distribution 表示一个 超指数分布

一个 k 阶段超指数分布是作为 k指数分布 的混合而获得的 连续概率分布。 它也被称为 混合指数分布 或并行 k 阶段指数分布

一个 k 阶段超指数分布由两个参数表征,即一个 阶段概率向量 α=(α1,...,αk) 和一个 速率向量 λ=(λ1,...,λk)

随机变量 x 在超指数分布中的 概率密度函数 由下式给出

下图说明了具有五个不同参数的超指数分布的 PDF,即

  1. α=(1.0)λ=(1.0)(退化为简单的指数分布),
  2. α=(0.1, 0.9)λ=(0.5, 1.5)
  3. α=(0.9, 0.1)λ=(0.5, 1.5)
  4. α=(0.2, 0.3, 0.5)λ=(0.5, 1.0, 1.5)
  5. α=(0.5, 0.3, 0.2)λ=(0.5, 1.0, 1.5)

此外,下图说明了超指数分布的 PDF(实线),其中只有 阶段概率向量 发生变化,以及两个极限指数分布的 PDF(虚线)

  1. α=(0.1, 0.9)λ=(0.5, 1.5)
  2. α=(0.6, 0.4)λ=(0.5, 1.5)
  3. α=(0.9, 0.1)λ=(0.5, 1.5)
  4. 参数为 λ=0.5 的指数分布,
  5. 参数为 λ=1.5 的指数分布。

正如预期的那样,当 阶段概率向量 的第一个元素 α1 接近 1 时(或者,等效地,α2 接近 0 时),得到的超指数分布接近参数为 λ=0.5 的指数分布。 相反,当 阶段概率向量 的第一个元素 α2 接近 1 时(或者,等效地,α1 接近 0 时),得到的超指数分布接近参数为 λ=1.5 的指数分布。

最后,下图比较了具有不同阶段数但平均值都等于 2 的超指数分布的 PDF

  1. α=(1.0)λ=(2.0)(退化为简单的指数分布),
  2. α=(0.5, 0.5)λ=(0.3, 1.5)
  3. α=(1.0/3.0, 1.0/3.0, 1.0/3.0)λ=(0.2, 1.5, 3.0)

可以看出,即使这三个分布具有相同的平均值,但与指数分布相比,两个超指数分布都具有 更长的 尾部。 实际上,超指数分布比指数分布具有更大的变异性,因此导致 变异系数 大于 1(与指数分布的变异系数正好为 1 相对)。

应用

一个 k 阶段超指数分布常用于 排队论 中,以模拟 k 个独立事件的叠加分布,例如,具有 k 个并行服务器的排队站的服务时间分布,其中第 i 个服务器以概率 αi 被选择,并且其服务时间分布是速率为 λi 的指数分布 (Allen,1990; Papadopolous et al.,1993; Trivedi,2002)。

例如,计算系统中 CPU 的服务时间分布通常被观察到具有这种分布 (Rosin,1965)。 此外,不同类型的客户到达单个排队站通常被建模为超指数分布 (Papadopolous et al.,1993)。 类似地,如果产品在多个并行装配线中制造并且输出被合并,则整体产品的故障密度很可能是超指数分布 (Trivedi,2002)。

最后,由于超指数分布表现出较高的变异系数 (CoV),即 CoV > 1,因此它特别适合拟合具有较大 CoV 的经验数据 (Feitelson,2014; Wolski et al.,2013) 并近似 长尾概率分布 (Feldmann et al.,1998)。

相关分布

示例

电器的寿命

假设客户正在购买电器,并在平均寿命为 10 年的电器和平均寿命为 12 年的电器之间随机选择。 假设此电器的寿命服从指数分布,则购买的电器的寿命分布可以建模为具有阶段概率向量 α=(1/2,1/2) 和速率向量 λ=(1/10,1/12) 的超指数分布 (Wolfram,2014)。

在本节的其余部分,我们提供了一个 C++ 实现示例,用于计算电器的平均寿命以及电器工作超过 15 年的概率。

#include <boost/math/distributions/hyperexponential.hpp>
#include <iostream>
int main()
{
   const double rates[] = { 1.0 / 10.0, 1.0 / 12.0 };

   boost::math::hyperexponential he(rates);

   std::cout << "Average lifetime: "
      << boost::math::mean(he)
      << " years" << std::endl;
   std::cout << "Probability that the appliance will work for more than 15 years: "
      << boost::math::cdf(boost::math::complement(he, 15.0))
      << std::endl;
}

结果输出为

Average lifetime: 11 years
Probability that the appliance will work for more than 15 years: 0.254817
私有云计算系统的工作负载

云计算 已成为动态和安全地自助访问计算和存储能力的流行隐喻。 在 (Wolski et al.,2013) 中,作者分析并建模了从企业运营的商业 私有云 收集的工作负载,并表明 3 阶段超指数分布(使用 期望最大化算法 拟合)可以准确捕获工作负载属性。

在这种类型的计算系统中,用户请求包括请求配置一个或多个 虚拟机 (VM)。 特别是,在 (Wolski et al.,2013) 中,每个云系统经历的工作负载是四个分布的函数,每个分布对应以下工作负载属性之一

作者假设一个请求中的所有 VM 都具有相同的核心数,但请求大小和核心数可能因请求而异。 此外,假设一个请求中的所有 VM 都具有相同的生命周期。 鉴于这些假设,作者通过将各自的数据拟合到 3 阶段超指数分布,为请求到达间隔时间和 VM 生命周期属性构建了统计模型。

在下表中,我们显示了作者收集的三个数据集中请求到达间隔时间和 VM 生命周期分布的样本均值和标准差 (SD),单位为秒

数据集

平均请求到达间隔时间(标准差)

平均多核 VM 生命周期(标准差)

平均单核 VM 生命周期(标准差)

DS1

2202.1 (2.2e+04)

257173 (4.6e+05)

28754.4 (1.6e+05)

DS2

41285.7 (1.1e+05)

144669.0 (7.9e+05)

599815.0 (1.7e+06)

DS3

11238.8 (3.0e+04)

30739.2 (1.6e+05)

44447.8 (2.2e+05)

而在下表中,我们显示了拟合产生的超指数分布参数

数据集

请求到达间隔时间

多核 VM 生命周期

单核 VM 生命周期

DS1

α=(0.34561,0.08648,0.56791), λ=(0.008,0.00005,0.02894)

α=(0.24667,0.37948,0.37385), λ=(0.00004,0.000002,0.00059)

α=(0.09325,0.22251,0.68424), λ=(0.000003,0.00109,0.00109)

DS2

α=(0.38881,0.18227,0.42892), λ=(0.000006,0.05228,0.00081)

α=(0.42093,0.43960,0.13947), λ=(0.00186,0.00008,0.0000008)

α=(0.44885,0.30675,0.2444), λ=(0.00143,0.00005,0.0000004)

DS3

α=(0.39442,0.24644,0.35914), λ=(0.00030,0.00003,0.00257)

α=(0.37621,0.14838,0.47541), λ=(0.00498,0.000005,0.00022)

α=(0.34131,0.12544,0.53325), λ=(0.000297,0.000003,0.00410)

在本节的其余部分,我们提供了一个 C++ 实现示例,用于计算每个分析数据集的拟合分布的一些统计属性。

#include <boost/math/distributions.hpp>
#include <iostream>
#include <string>

struct ds_info
{
   std::string name;
   double iat_sample_mean;
   double iat_sample_sd;
   boost::math::hyperexponential iat_he;
   double multi_lt_sample_mean;
   double multi_lt_sample_sd;
   boost::math::hyperexponential multi_lt_he;
   double single_lt_sample_mean;
   double single_lt_sample_sd;
   boost::math::hyperexponential single_lt_he;
};

// DS1 dataset
ds_info make_ds1()
{
   ds_info ds;

   ds.name = "DS1";

   // VM interarrival time distribution
   const double iat_fit_probs[] = { 0.34561,0.08648,0.56791 };
   const double iat_fit_rates[] = { 0.0008,0.00005,0.02894 };
   ds.iat_sample_mean = 2202.1;
   ds.iat_sample_sd = 2.2e+4;
   ds.iat_he = boost::math::hyperexponential(iat_fit_probs, iat_fit_rates);

   // Multi-core VM lifetime distribution
   const double multi_lt_fit_probs[] = { 0.24667,0.37948,0.37385 };
   const double multi_lt_fit_rates[] = { 0.00004,0.000002,0.00059 };
   ds.multi_lt_sample_mean = 257173;
   ds.multi_lt_sample_sd = 4.6e+5;
   ds.multi_lt_he = boost::math::hyperexponential(multi_lt_fit_probs, multi_lt_fit_rates);

   // Single-core VM lifetime distribution
   const double single_lt_fit_probs[] = { 0.09325,0.22251,0.68424 };
   const double single_lt_fit_rates[] = { 0.000003,0.00109,0.00109 };
   ds.single_lt_sample_mean = 28754.4;
   ds.single_lt_sample_sd = 1.6e+5;
   ds.single_lt_he = boost::math::hyperexponential(single_lt_fit_probs, single_lt_fit_rates);

   return ds;
}

// DS2 dataset
ds_info make_ds2()
{
   ds_info ds;

   ds.name = "DS2";

   // VM interarrival time distribution
   const double iat_fit_probs[] = { 0.38881,0.18227,0.42892 };
   const double iat_fit_rates[] = { 0.000006,0.05228,0.00081 };
   ds.iat_sample_mean = 41285.7;
   ds.iat_sample_sd = 1.1e+05;
   ds.iat_he = boost::math::hyperexponential(iat_fit_probs, iat_fit_rates);

   // Multi-core VM lifetime distribution
   const double multi_lt_fit_probs[] = { 0.42093,0.43960,0.13947 };
   const double multi_lt_fit_rates[] = { 0.00186,0.00008,0.0000008 };
   ds.multi_lt_sample_mean = 144669.0;
   ds.multi_lt_sample_sd = 7.9e+05;
   ds.multi_lt_he = boost::math::hyperexponential(multi_lt_fit_probs, multi_lt_fit_rates);

   // Single-core VM lifetime distribution
   const double single_lt_fit_probs[] = { 0.44885,0.30675,0.2444 };
   const double single_lt_fit_rates[] = { 0.00143,0.00005,0.0000004 };
   ds.single_lt_sample_mean = 599815.0;
   ds.single_lt_sample_sd = 1.7e+06;
   ds.single_lt_he = boost::math::hyperexponential(single_lt_fit_probs, single_lt_fit_rates);

   return ds;
}

// DS3 dataset
ds_info make_ds3()
{
   ds_info ds;

   ds.name = "DS3";

   // VM interarrival time distribution
   const double iat_fit_probs[] = { 0.39442,0.24644,0.35914 };
   const double iat_fit_rates[] = { 0.00030,0.00003,0.00257 };
   ds.iat_sample_mean = 11238.8;
   ds.iat_sample_sd = 3.0e+04;
   ds.iat_he = boost::math::hyperexponential(iat_fit_probs, iat_fit_rates);

   // Multi-core VM lifetime distribution
   const double multi_lt_fit_probs[] = { 0.37621,0.14838,0.47541 };
   const double multi_lt_fit_rates[] = { 0.00498,0.000005,0.00022 };
   ds.multi_lt_sample_mean = 30739.2;
   ds.multi_lt_sample_sd = 1.6e+05;
   ds.multi_lt_he = boost::math::hyperexponential(multi_lt_fit_probs, multi_lt_fit_rates);

   // Single-core VM lifetime distribution
   const double single_lt_fit_probs[] = { 0.34131,0.12544,0.53325 };
   const double single_lt_fit_rates[] = { 0.000297,0.000003,0.00410 };
   ds.single_lt_sample_mean = 44447.8;
   ds.single_lt_sample_sd = 2.2e+05;
   ds.single_lt_he = boost::math::hyperexponential(single_lt_fit_probs, single_lt_fit_rates);

   return ds;
}

void print_fitted(ds_info const& ds)
{
   const double secs_in_a_hour = 3600;
   const double secs_in_a_month = 30 * 24 * secs_in_a_hour;

   std::cout << "### " << ds.name << std::endl;
   std::cout << "* Fitted Request Interarrival Time" << std::endl;
   std::cout << " - Mean (SD): " << boost::math::mean(ds.iat_he) << " (" << boost::math::standard_deviation(ds.iat_he) << ") seconds." << std::endl;
   std::cout << " - 99th Percentile: " << boost::math::quantile(ds.iat_he, 0.99) << " seconds." << std::endl;
   std::cout << " - Probability that a VM will arrive within 30 minutes: " << boost::math::cdf(ds.iat_he, secs_in_a_hour / 2.0) << std::endl;
   std::cout << " - Probability that a VM will arrive after 1 hour: " << boost::math::cdf(boost::math::complement(ds.iat_he, secs_in_a_hour)) << std::endl;
   std::cout << "* Fitted Multi-core VM Lifetime" << std::endl;
   std::cout << " - Mean (SD): " << boost::math::mean(ds.multi_lt_he) << " (" << boost::math::standard_deviation(ds.multi_lt_he) << ") seconds." << std::endl;
   std::cout << " - 99th Percentile: " << boost::math::quantile(ds.multi_lt_he, 0.99) << " seconds." << std::endl;
   std::cout << " - Probability that a VM will last for less than 1 month: " << boost::math::cdf(ds.multi_lt_he, secs_in_a_month) << std::endl;
   std::cout << " - Probability that a VM will last for more than 3 months: " << boost::math::cdf(boost::math::complement(ds.multi_lt_he, 3.0*secs_in_a_month)) << std::endl;
   std::cout << "* Fitted Single-core VM Lifetime" << std::endl;
   std::cout << " - Mean (SD): " << boost::math::mean(ds.single_lt_he) << " (" << boost::math::standard_deviation(ds.single_lt_he) << ") seconds." << std::endl;
   std::cout << " - 99th Percentile: " << boost::math::quantile(ds.single_lt_he, 0.99) << " seconds." << std::endl;
   std::cout << " - Probability that a VM will last for less than 1 month: " << boost::math::cdf(ds.single_lt_he, secs_in_a_month) << std::endl;
   std::cout << " - Probability that a VM will last for more than 3 months: " << boost::math::cdf(boost::math::complement(ds.single_lt_he, 3.0*secs_in_a_month)) << std::endl;
}

int main()
{
   print_fitted(make_ds1());

   print_fitted(make_ds2());

   print_fitted(make_ds3());
}

结果输出(浮点精度设置为 2)为

### DS1
* Fitted Request Interarrival Time
 - Mean (SD): 2.2e+03 (8.1e+03) seconds.
 - 99th Percentile: 4.3e+04 seconds.
 - Probability that a VM will arrive within 30 minutes: 0.84
 - Probability that a VM will arrive after 1 hour: 0.092
* Fitted Multi-core VM Lifetime
 - Mean (SD): 2e+05 (3.9e+05) seconds.
 - 99th Percentile: 1.8e+06 seconds.
 - Probability that a VM will last for less than 1 month: 1
 - Probability that a VM will last for more than 3 months: 6.7e-08
* Fitted Single-core VM Lifetime
 - Mean (SD): 3.2e+04 (1.4e+05) seconds.
 - 99th Percentile: 7.4e+05 seconds.
 - Probability that a VM will last for less than 1 month: 1
 - Probability that a VM will last for more than 3 months: 6.9e-12
### DS2
* Fitted Request Interarrival Time
 - Mean (SD): 6.5e+04 (1.3e+05) seconds.
 - 99th Percentile: 6.1e+05 seconds.
 - Probability that a VM will arrive within 30 minutes: 0.52
 - Probability that a VM will arrive after 1 hour: 0.4
* Fitted Multi-core VM Lifetime
 - Mean (SD): 1.8e+05 (6.4e+05) seconds.
 - 99th Percentile: 3.3e+06 seconds.
 - Probability that a VM will last for less than 1 month: 0.98
 - Probability that a VM will last for more than 3 months: 0.00028
* Fitted Single-core VM Lifetime
 - Mean (SD): 6.2e+05 (1.6e+06) seconds.
 - 99th Percentile: 8e+06 seconds.
 - Probability that a VM will last for less than 1 month: 0.91
 - Probability that a VM will last for more than 3 months: 0.011
### DS3
* Fitted Request Interarrival Time
 - Mean (SD): 9.7e+03 (2.2e+04) seconds.
 - 99th Percentile: 1.1e+05 seconds.
 - Probability that a VM will arrive within 30 minutes: 0.53
 - Probability that a VM will arrive after 1 hour: 0.36
* Fitted Multi-core VM Lifetime
 - Mean (SD): 3.2e+04 (1e+05) seconds.
 - 99th Percentile: 5.4e+05 seconds.
 - Probability that a VM will last for less than 1 month: 1
 - Probability that a VM will last for more than 3 months: 1.9e-18
* Fitted Single-core VM Lifetime
 - Mean (SD): 4.3e+04 (1.6e+05) seconds.
 - 99th Percentile: 8.4e+05 seconds.
 - Probability that a VM will last for less than 1 month: 1
 - Probability that a VM will last for more than 3 months: 9.3e-12
[Note] 注意

以上结果与 (Wolski et al.,2013) 表格 III、V 和 VII 中显示的结果不同。 我们使用 Wolfram Mathematica 10 仔细复核了它们,结果证实了我们的结果。

成员函数

默认构造函数
hyperexponential_distribution();

构造一个速率为 11 阶段超指数分布(即,指数分布)。

从迭代器构造
template <typename ProbIterT, typename RateIterT>
hyperexponential_distribution(ProbIterT prob_first, ProbIterT prob_last,
                              RateIterT rate_first, RateIterT rate_last);

构造一个超指数分布,其 阶段概率向量 参数由 [prob_first, prob_last) 迭代器对定义的范围给出,并且 速率向量 参数由 [rate_first, rate_last) 迭代器对定义的范围给出。

参数
类型要求
示例
std::array<double, 2> phase_prob = { 0.5, 0.5 };
std::array<double, 2> rates = { 1.0 / 10, 1.0 / 12 };

hyperexponential he(phase_prob.begin(), phase_prob.end(), rates.begin(), rates.end());
从范围/容器构造
template <typename ProbRangeT, typename RateRangeT>
hyperexponential_distribution(ProbRangeT const& prob_range,
                              RateRangeT const& rate_range);

构造一个超指数分布,其 阶段概率向量 参数由 prob_range 定义的范围给出,并且 速率向量 参数由 rate_range 定义的范围给出。

[Note] 注意

作为实现细节,此构造函数使用 Boost 的 enable_if/disable_if 机制 来消除此构造函数与其他 2 参数构造函数之间的歧义。 有关更多详细信息,请参阅源代码。

参数
类型要求
示例
// We could be using any standard library container here... vector, deque, array, list etc:
std::array<double, 2> phase_prob = { 0.5, 0.5 };
std::array<double, 2> rates      = { 1.0 / 10, 1.0 / 12 };

hyperexponential he1(phase_prob, rates);    // Construct from standard library container.

double phase_probs2[] = { 0.5, 0.5 };
double rates2[]       = { 1.0 / 10, 1.0 / 12 };

hyperexponential he2(phase_probs2, rates2);  // Construct from native C++ array.
使用速率迭代器构造(所有阶段概率相等)
template <typename RateIterT, typename RateIterT2>
hyperexponential_distribution(RateIterT const& rate_first,
                              RateIterT2 const& rate_last);

构造一个超指数分布,其 速率向量 参数由 [rate_first, rate_last) 迭代器对定义的范围给出,并且 阶段概率向量 设置为相等的阶段概率(即,设置为与 速率向量 的长度 n 相同的向量,并且每个元素设置为 1.0/n)。

[Note] 注意

作为实现细节,此构造函数使用 Boost 的 enable_if/disable_if 机制 来消除此构造函数与其他 2 参数构造函数之间的歧义。 有关更多详细信息,请参阅源代码。

参数
类型要求
示例
// We could be using any standard library container here... vector, deque, array, list etc:
std::array<double, 2> rates = { 1.0 / 10, 1.0 / 12 };

hyperexponential he(rates.begin(), rates.end());

BOOST_MATH_ASSERT(he.probabilities()[0] == 0.5); // Phase probabilities will be equal and normalised to unity.
从单个速率范围构造(所有阶段概率将相等)
template <typename RateRangeT>
hyperexponential_distribution(RateRangeT const& rate_range);

构造一个超指数分布,其 速率向量 参数由 rate_range 定义的范围给出,并且 阶段概率向量 设置为相等的阶段概率(即,设置为与 速率向量 的长度 n 相同的向量,并且每个元素设置为 1.0/n)。

参数
类型要求
示例
std::array<double, 2> rates = { 1.0 / 10, 1.0 / 12 };

hyperexponential he(rates);

BOOST_MATH_ASSERT(he.probabilities()[0] == 0.5); // Phase probabilities will be equal and normalised to unity.
从初始化列表构造
hyperexponential_distribution(std::initializer_list<RealType> l1, std::initializer_list<RealType> l2);

构造一个超指数分布,其 阶段概率向量 参数由 l1 定义的 花括号初始化列表 给出,并且 速率向量 参数由 l2 定义的 花括号初始化列表 给出。

参数

阶段概率列表和速率列表的元素数量必须相同。

示例
hyperexponential he = { { 0.5, 0.5 }, { 1.0 / 10, 1.0 / 12 } };
从单个初始化列表构造(所有阶段概率将相等)
hyperexponential_distribution(std::initializer_list<RealType> l1);

构造一个超指数分布,其 速率向量 参数由 l1 定义的 花括号初始化列表 给出,并且 阶段概率向量 设置为相等的阶段概率(即,设置为与 速率向量 的长度 n 相同的向量,并且每个元素设置为 1.0/n)。

参数
示例
hyperexponential he = { 1.0 / 10, 1.0 / 12 };

BOOST_MATH_ASSERT(he.probabilities()[0] == 0.5);
访问器
std::size_t num_phases() const;

获取此分布的阶段数(速率向量和概率向量的大小)。

返回值

一个非负整数,表示此分布的阶段数。

std::vector<RealType> probabilities() const;

获取此分布的 阶段概率向量 参数。

[Note] 注意

返回的概率是在构造时传递的概率参数值的 归一化 版本。

返回值

一个非负实数向量,表示此分布的 阶段概率向量 参数。

std::vector<RealType> rates() const;

获取此分布的 速率向量 参数。

返回值

一个正实数向量,表示此分布的 速率向量 参数。

[Warning] 警告

这些函数的返回类型是按值返回的向量。 这是故意的,因为我们希望隐藏内部使用的实际容器,该容器可能会在未来发生更改(例如,为了方便 cdf 代码的向量化等)。 用户应注意,某些原本可能期望工作的代码不起作用。 例如,尝试输出(归一化的)概率

std::copy(he.probabilities().begin(), he.probabilities().end(), std::ostream_iterator<double>(std::cout, " "));

在编译或运行时失败,因为迭代器类型不兼容,但是,例如,

std::cout << he.probabilities()[0] << ' ' << he.probabilities()[1] << std::endl;

输出期望值。

一般来说,如果您想访问返回容器的成员,请首先赋值给变量,然后访问这些成员

std::vector<double> t = he.probabilities();
std::copy(t.begin(), t.end(), std::ostream_iterator<double>(std::cout, " "));

非成员访问器函数

支持所有 通常的非成员访问器函数,这些函数是所有分布通用的: 累积分布函数, 概率密度函数, 分位数, 风险函数, 累积风险函数, __logcdf, __logpdf, 均值, 中位数, 众数, 方差, 标准差, 偏度, 峰度, 超额峰度, 范围支持

下表显示了用于计算这些值的公式。

精度

超指数分布是根据 指数分布 实现的,因此应该具有非常小的误差,通常是 epsilon 或几个。

实现

在下表中

函数

实现说明

支持域

x ∈ [0,∞)

pdf

cdf

cdf 补函数

分位数

没有闭合形式解。数值计算。

补函数分位数

没有闭合形式解。数值计算。

均值

方差

众数

0

偏度

峰度

超额峰度

峰度 - 3

参考文献


PrevUpHomeNext