dlsun / symbulate

A symbolic algebra for specifying simulations.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add Multinomial distribution

kevindavisross opened this issue · comments

I copy paste from Binomial Dist and modified some codes but I got error and stuck at the super().__init__(params, stats.multinomial, True) . Here is my code:
image

It gives this AttributeError and I have no idea how to fix it.
image

  • 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)