Enumerating discrete distributions
- 主要语言
- Haskell
- 星标
- 309
- 派生
- 76
- PR 合并指标
- 30 天内没有已合并 PR
描述
I have quite a few applications where I need to compute the pdf (or cdf) of a discrete distribution over the whole range [n, n+1, ..., n+N]. At the moment, that requires calling the pdf (or cdf) function for each value in the range. However, for many distributions it's much quicker to calculate the first case and then use your knowledge of the distribution to calculate the values for [n+1, ..., n+N]. You then end up with an unfolding operation:
``` haskell
pdfFromTo :: (DiscreteDistribution d, Vector v Double) => d -> Int -> Int -> v Double
```
which for the binomial distribution would look like
``` haskell
-- assume 0 <= n0 <= n1 <= n for simplicity
pdfFromTo binDist n0 n1 = iterateN (n1 - n0) (\x -> x * (n-k) * p / (k+1) / (1-p)) (probability binDist n0)
```
贡献指南
这个仓库没有索引到贡献指南
评估
这个 Issue 还没有评估数据。