This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Probability function of the binomial distribution

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.


stats::binomialPF(n, p)


stats::binomialPF(n, p) returns a procedure representing the probability function

for x=0,1,..,n of the binomial distribution with “trial parameter” n and “probability parameter” p.

The procedure f := stats::binomialPF(n, p) can be called in the form f(x) with arithmetical expressions x. The return value of f(x) is either a floating-point number, an exact numerical value, or a symbolic expression:

  • If x is a non-integer numerical value, f(x) returns 0 or 0.0, respectively.

  • If x is an integer or the floating point equivalent of an integer and n is a positive integer, then an explicit value is returned. If p is a numerical value satisfying 0 ≤ p ≤ 1, this is a numerical value. Otherwise, it is a symbolic expression in p.

    For symbolic values of n, explicit results are returned if x is a numerical value withx < 2.

  • For symbolic values of n, explicit results are returned if n - x is a numerical value withn - x < 2.

  • In all other cases, f(x) returns the symbolic call stats::binomialPF(n,p)(x).

Numerical values for n are only accepted if they are positive integers.

Numerical values for p are only accepted if they satisfy 0 ≤ p ≤ 1.

If x is a floating-point number, the result is a floating number provided n and p are numerical values. If x is an exact value, the result is an exact number.

Note that for large n, floating-point results are computed much faster than exact results. If floating-point approximations are desired, pass a floating-point number x to the procedure created by stats::binomialPF.

Environment Interactions

The function is sensitive to the environment variable DIGITS which determines the numerical working precision.


Example 1

We compute the probability function with n = 3 and at various points:

f := stats::binomialPF(3, 3/4): 
f(-1/2), f(0), f(1/2), f(1), f(7/4), f(2), f(3), f(4)

f(-0.2), f(0.0), f(0.7), f(1.0), f(2.0), f(2.7), f(3.0), f(4.0)

delete f:

Example 2

We use symbolic arguments:

f := stats::binomialPF(n, p): f(x), f(8), f(8.0)

When real numbers are assigned to n and p, the function f starts to produce explicit results if the argument is numerical:

n := 3: p := 1/3:
f(0), f(1), f(2.0), f(3.5), f(4)

delete f, n, p, x:

Example 3

If n and x are numerical, symbolic expressions are returned for symbolic values of p:

f := stats::binomialPF(3, p):
f(-1), f(0), f(3/2), f(2), f(3)

delete f:



The “trial parameter”: an arithmetical expression representing a positive integer


The “probability parameter”: an arithmetical expression representing a real number 0 ≤ p ≤ 1.

Return Values


Was this topic helpful?