Add Multinomial distribution
kevindavisross opened this issue · 2 comments
kevindavisross commented
Add Multinomial distribution
hayate0304 commented
kevindavisross commented
- While Multinomial has some analogies with Binomial, from the coding perspective it will help to look at MultivariateNormal. A realization from a Binomial distribution is a number, but a realization from a Multinomial or MultivariateNormal is a vector.
- Multinomial is the first multivariate discrete distribution we will be adding, so might require a little more work than just copying and modifying existing code.
- We currently don't have capability to plot the true pdf/pmf for multivariate distributions, so you don't need to add that, i.e. you do NOT need Multinomial().plot(). But you should add ability to plot a scatterplot for simulated values from a Multinomial distribution, like below
- Basically, Multinomial should be able to do everything that MultivariateNormal can do, but Multinomial will be discrete. Your code will mix elements from MultivariateNormal and Binomial, and from general discrete X, discrete Y situations.
X, Y, Z = RV(Multinomial(n=10, p=[0.1, 0.3, 0.6]))
(X & Y).sim(10000).plot() # should produce a scatter plot (check default settings for other two discrete plots)
You can use properties of Multinomial distributions to test your code. For example, in above example
- X is Binomial(10, 0.1)
- (X+Y) is Binomial(10, 0.1 + 0.3)
- (X | (Z == 4)) is Binomial(10 - 4, 0.1/(1-0.6))
- Cov(X, Y) = -10(0.1)(0.3)