Accelerating the pace of engineering and science

# stats::finiteCDF

Cumulative distribution function of a finite sample space

### Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

## Syntax

```stats::finiteCDF([x1, x2, …], [p1, p2, …])
stats::finiteCDF([[x1, p1], [x2, p2], …])
stats::finiteCDF(s, <c1, c2>)
stats::finiteCDF(s, <[c1, c2]>)
```

## Description

stats::finiteCDF([x1, x2, …, xn], [p1, p2, …, pn]) returns a procedure representing the cumulative distribution function of the finite sample space consisting of the data elements x1, …, xn with the probabilities p1, …, pn. Here, , i.e., xk is the largest element of the data sample less or equal to x (the data elements are assumed to be ordered: x1 < x2 < x3 etc.)

The procedure f := stats::finiteCDF([x1, x2, …], [p1, p2, …]) can be called in the form f(x) with an arithmetical expression x.

If x is a numerical value and the data elements x1, x2, … are all numerical, then f(x) returns an arithmetical expression (the sum of the probabilities of all data elements smaller or equal to x).

The call f(- infinity ) produces 0; the call f( infinity ) produces 1.

Otherwise, if x is a symbolic expression that cannot be converted to a real floating-point number or if the data x1, x2, … contain elements that cannot be converted to real floating-point numbers, then f(x) returns the symbolic call stats::finiteCDF([x1, x2, …], [p1, p2, …])(x) with the data x1, x2, … in ascending order.

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

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

The data elements x1, x2, … are assumed to be in ascending order: x1 < x2 < …. If all data elements are numerical, they are re-ordered automatically, if they are not ascending. If the data contain symbolic elements that cannot be converted to floating-point numbers, the ordering is assumed implicitly.

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

## Environment Interactions

The function is sensitive to the environment variable DIGITS which determines the numerical working precision. Note, however, that this function is implemented with option remember. After the first call it does not react to changes of DIGITS unless the input parameters are changed.

## Examples

### Example 1

We evaluate the finite distribution function of some numerical data at various points:

```f := stats::finiteCDF([1, 0, 2.3, PI], [p1, p0, 0.2, 0.3]):
f(-infinity), f(0.1), f(2.3), f(PI), f(10), f(infinity)```

Alternatively, the data may be passed as a list:

```f := stats::finiteCDF([[1, p1], [0, p0], [2.3, 0.2], [PI, 0.3]]):
f(-infinity), f(0.1), f(2.3), f(PI), f(10), f(infinity)```

`delete f:`

### Example 2

We use symbolic arguments. In the symbolic return value, the input data appear as a sorted list:

`stats::finiteCDF([3, 4, PI], [0.2, 0.5, 0.3])(x)`

If the data contain symbolic elements, the return value is again a symbolic call:

`stats::finiteCDF([3, x, PI], [0.2, 0.5, 0.3])(0.7)`

### Example 3

We create a 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 compute values of the finite distributions of the data in the second and third column:

```f := stats::finiteCDF(s, 2, 3):
f(1000), f(1200), f(1201)```

`delete s, f:`

### Example 4

If numerical probability values are given, they must add up to 1:

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

Symbolic probability values are not checked for consistency:

```f := stats::finiteCDF([Head, TAIL], [0.45, p]):
f(x)```

However, when the probabilities are set to numerical values, they are checked:

`p:= 0.7: f(x)`
```Error: The probabilities do not add up to one. [f]
```
`delete f, p:`

### Example 5

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

```f:= stats::finiteCDF([x1, x2, x1, x2], [0.1, 0.2, 0.3, 0.4]):
f(3)```

`x1 := 1: x2 := 3: f(2)`

`delete f, x1, x2:`

## 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.