Saturday, April 4, 2026
HomeLanguagessympy.stats.NegativeMultinomial() function in Python

sympy.stats.NegativeMultinomial() function in Python

With the help of sympy.stats.NegativeMultinomial() method, we can create a discrete random variable with Negative Multinomial Distribution.

Syntax: sympy.stats.NegativeMultinomial(syms, k, p)

Parameters: 
 syms: the symbol
 k: number of failures before the experiment is stopped, a positive integer
 p: event probabilites, p>= 0 and p<= 1

Returns: a discrete random variable with Negative Multinomial Distribution.

Example #1 :

Python3




# import sympy, NegativeMultinomia, density, symbols
from sympy.stats import density
from sympy.stats.joint_rv_types import NegativeMultinomial
from sympy import symbols, pprint
  
p1, p2, p3 = symbols('p1, p2, p3', positive = True)
x1, x2, x3 = symbols('x1, x2, x3', nonnegative = True, integer = True)
  
# using sympy.stats.NegativeMultinomial() method
N = NegativeMultinomial('N', 3, p1, p2, p3)
negMulti = density(N)(x1, x2, x3)
  
pprint(negMulti)


Output :

  x1   x2   x3                    3                        
p1  *p2  *p3  *(-p1 - p2 - p3 + 1) *Gamma(x1 + x2 + x3 + 3)
-----------------------------------------------------------
                       2*x1!*x2!*x3!   

Example #2 :

Python3




# import sympy, NegativeMultinomia, density, symbols
from sympy.stats import density
from sympy.stats.joint_rv_types import NegativeMultinomial
from sympy import symbols, pprint
  
x1, x2, x3 = symbols('x1, x2, x3', nonnegative = True, integer = True)
  
# using sympy.stats.NegativeMultinomial() method
N = NegativeMultinomial('N', 2, 1 / 3, 1 / 2)
negMulti = density(N)(x1, x2, x3)
  
pprint(negMulti)


Output :

 -x2  -x1                        
2   *3   *Gamma(x1 + x2 + x3 + 2)
---------------------------------
            36*x1!*x 
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32512 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6886 POSTS0 COMMENTS
Nicole Veronica
12007 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12100 POSTS0 COMMENTS
Shaida Kate Naidoo
7015 POSTS0 COMMENTS
Ted Musemwa
7259 POSTS0 COMMENTS
Thapelo Manthata
6972 POSTS0 COMMENTS
Umr Jansen
6960 POSTS0 COMMENTS