Home Libraries People FAQ More

#### 離散分位點函數(Discrete Quantile Policies)

enum discrete_quantile_policy_type { real, integer_round_outwards, // 缺省

integer_round_inwards, integer_round_down, integer_round_up, integer_round_nearest }; template <discrete_quantile_policy_type> struct discrete_quantile;

`discrete_quantile` 可以接收的值具有以下含義：

###### real

```#include <boost/math/distributions/negative_binomial.hpp>

using namespace boost::math;
using namespace boost::math::policies;

typedef negative_binomial_distribution<
double,
policy<discrete_quantile<integer_round_inwards> >
> dist_type;

// 下分位點:
double x = quantile(dist_type(20, 0.3), 0.05);
// 上分位點:
double y = quantile(complement(dist_type(20, 0.3), 0.05));

```

###### integer_round_outwards

• 下分位點 (概率小於0.5)向下捨入
• 上分位點 (概率大於0.5)向上捨入

```#include <boost/math/distributions/negative_binomial.hpp>

using namespace boost::math;

// 下分位點向下捨入:
double x = quantile(negative_binomial(20, 0.3), 0.05);
// 上分位點向上捨入:
double y = quantile(complement(negative_binomial(20, 0.3), 0.05));

```

```cdf(negative_binomial(20), x) <= 0.05
cdf(negative_binomial(20), y) >= 0.95
```

###### integer_round_inwards

• 下分位點 (概率小於0.5)向上捨入
• 上分位點 (概率大於0.5)向下捨入

```#include <boost/math/distributions/negative_binomial.hpp>

using namespace boost::math;
using namespace boost::math::policies;

typedef negative_binomial_distribution<
double,
policy<discrete_quantile<integer_round_inwards> >
> dist_type;

// 下分位點向上捨入:
double x = quantile(dist_type(20, 0.3), 0.05);
// 上分位點向下捨入:
double y = quantile(complement(dist_type(20, 0.3), 0.05));

```

```cdf(negative_binomial(20), x) >= 0.05
cdf(negative_binomial(20), y) <= 0.95
```

###### integer_round_nearest

```#include <boost/math/distributions/negative_binomial.hpp>

using namespace boost::math;
using namespace boost::math::policies;

typedef negative_binomial_distribution<
double,
policy<discrete_quantile<integer_round_nearest> >
> dist_type;

// 下分位點向上捨入:
double x = quantile(dist_type(20, 0.3), 0.05);
// 上分位點向下捨入:
double y = quantile(complement(dist_type(20, 0.3), 0.05));

```

 Copyright 頲006 , 2007, 2008 John Maddock, Paul A. Bristow, Hubert Holin, Xiaogang Zhang and Bruno Lalande Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)