haskell / haskell/statistics

Enumerating discrete distributions

未关闭
#89 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
help needed
主要语言
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 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。