Enumerating discrete distributions
- Vorherrschende Sprache
- Haskell
- Sterne
- 309
- Forks
- 76
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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)
```
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Bewertung
Dieses Issue wurde noch nicht bewertet.