discreteUniformPdf

Evaluates the discrete uniform probability density function (PDF).

Synopsis

discreteUniformPdf(ix, n)

Required Arguments

int ix (Input)
Argument for which the discrete uniform PDF is to be evaluated. ix must be positive.
int n (Input)
Scale parameter. n must be positive.

Return Value

The probability that a random variable from a discrete uniform distribution with scale parameter n will be equal to ix. A value of NaN is returned if an input value is in error.

Description

The function discreteUniformPdf evaluates the discrete uniform probability density function (PDF) with scale parameter n, defined

\[p = f(I|N) = \frac{1}{N}, \phantom{...} 1 \leq I \leq N\]

where I = ix and N = n. As a convenience to the user, discreteUniformPdf accepts values of \(I>N\), returning \(p= 0\). discreteUniformPdf returns an error message for values of \(I\leq 0\).

Example

In this example, we evaluate the discrete uniform PDF at ix = 3, n = 5.

from __future__ import print_function
from numpy import *
from pyimsl.stat.discreteUniformPdf import discreteUniformPdf

ix = 3
n = 5

p = discreteUniformPdf(ix, n)
print("The probability density of a discrete uniform")
print("random variable with scale parameter n = %1i" % n)
print("and value ix = %1i is %6.4f" % (ix, p))

Output

The probability density of a discrete uniform
random variable with scale parameter n = 5
and value ix = 3 is 0.2000