stats::finitePF

Probability function of a finite sample space

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

Syntax

stats::finitePF([x1, x2, …], [p1, p2, …])
stats::finitePF([[x1, p1], [x2, p2], …])
stats::finitePF(n, <c1, c2>)
stats::finitePF(n, <[c1, c2]>)

Description

stats::finitePF([x1, x2, …, xn], [p1, p2, …, pn]) returns a procedure representing the probability function

of the sample space given by the data x1, x2, … with the probabilities p1, p2, ….

The procedure f := stats::finitePF([x1, x2, …], [p1, p2, …]) can be called in the form f(x) with an arithmetical expression x or sets of lists of such expressions.

If x is an expression that is contained in the data x1, x2, …, then the corresponding probability value is returned.

If x is an expression that is not contained in the data x1, x2, …, then 0 is returned.

If x is a set, the sum of the probability values of its elements is returned.

If x is a list, it is treated like a set (i.e., duplicate entries in x are eliminated). The sum of the probability values of the elements in x is returned.

If all probability values p1, p2, … are numerical, they must add up to 1. Otherwise, an error is raised. Cf. Example 4.

Duplicate data elements are automatically combined to a single data element, adding up the corresponding probability values. Cf. Example 5.

stats::finitePF generalizes stats::empiricalPF, which assumes equiprobable data. For numerical data x1, x2, …, the call stats::finitePF([x_1, dots, x_n], [1/n, dots, 1/n]) corresponds to stats::empiricalPF([x1, …, xn]).

Examples

Example 1

We demonstrate the basic usage of this function:

f := stats::finitePF([1, x, y, PI], [1/4, px, py, 0.25]):
f(0), f(1), f(1.0), f(x), f(y), f(PI), f(float(PI)), f(10)

Alternatively, the data may be passed as a list:

f := stats::finitePF([[1, 1/4], [x, px], [y, py], [PI, 0.25]]):
f(0), f(1), f(1.0), f(x), f(y), f(PI), f(float(PI)), f(10)

delete f:

Example 2

We create a sample of type stats::sample consisting of one string column and two non-string columns:

s := stats::sample(
  [["1996", 1242, 2/5],
   ["1997", 1353, 0.1],
   ["1998", 1142, 0.2],
   ["1999", 1201, 0.2],
   ["2001", 1201, 0.1]])
"1996"  1242  2/5
"1997"  1353  0.1
"1998"  1142  0.2
"1999"  1201  0.2
"2001"  1201  0.1

We use the data in the first and third column:

f := stats::finitePF(s, 1, 3):
f("1995"), f("1998"), f("2000"), f("2001")

delete s, f:

Example 3

We consider a loaded die:

f:= stats::finitePF([1, 2, 3, 4, 5, 6], 
                    [0.1, 0.1, 0.1, 0.2, 0.2, 0.3]):

What is the probabiliy that tossing the die produces a score more than or equal to 4?

f({4, 5, 6})

delete f:

Example 4

The probability values must add up to 1:

stats::finitePF([Head, TAIL], [0.45, 0.54]):
Error: The probabilities do not add up to one. [stats::finitePF]

Example 5

Duplicate data elements are automatically combined to a single data element, adding up the corresponding probability values:

f:= stats::finitePF([x1, x2, x1, x2], [0.1, 0.2, 0.3, 0.4]):
f(x1), f(x2)

delete f:

Parameters

x1, x2, …

The statistical data: arbitrary MuPAD® objects

p1, p2, …

Probability values: arithmetical expressions

s

A sample of domain type stats::sample

c1, c2

Column indices of the sample s: positive integers. Column c1 provides the data x1, x2 etc. Column c2 provides the data p1, p2 etc. There is no need to specify column numbers if the sample has only two columns.

Return Values

procedure.

Was this topic helpful?