DistrictDataLabs/blog-files — pull request #1 by ajschumacher (2014-09-21 18:19:50+00:00)
Title: minimal fix for broken dirichlet_mean function

Further, it might be better to write this all in a way that makes it clearer that `dirichlet_mean` is exactly equivalent to calling `bayesian_mean` with the right parameters (except the parameters are hidden in object properties, so it's weird that way too). Here's on hacky way to do it:

```
def dirichlet_mean(self, arr, prior=PRIOR):
"""
Computes the Dirichlet mean with a prior.
"""
self.confidence = float(sum(prior))
score_sum = sum([val * n for val, n in zip(range(1, 6), prior)])
self.prior = score_sum / self.confidence
return self.bayesian_mean(arr)
```