# Documentation

### This is machine translation

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

# `stats`::`empiricalPF`

Probability function of a finite data sample

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

## Syntax

```stats::empiricalPF(`x1, x2, …`)
stats::empiricalPF(`[x1, x2, …]`)
stats::empiricalPF(`n`, <`c`>)
stats::empiricalPF(`n`, <`[c]`>)
```

## Description

```stats::empiricalPF([x1, x2, …, xn])``` returns a procedure representing the probability function

of the sample given by the data ```x1, x2, …```.

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

If `x` is a numerical expression that is contained in the data ```x1, x2, …```, then the corresponding probability value is returned (n is the size of the sample).

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

If `x` is a symbolic expression that cannot be converted to a real floating-point number, `f(x)` returns the symbolic call ```stats::empiricalPF([x1, x2, …])````(x)` with the data ```x1, x2, …``` in ascending order.

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.

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

`stats::empiricalPF` is generalized by `stats::finitePF`, which allows to specify different probabilities for the elements of the sample. The call ```stats::empiricalPF([x_1, dots, x_n], [1/n, dots, 1/n])``` corresponds to ```stats::empiricalPF([x1, …, xn])```.

Further, `stats::finitePF` does not only allow numerical values ```x1, x2, …```, but arbitrary MuPAD® objects.

## Examples

### Example 1

We demonstrate the basic usage of this function:

```f := stats::empiricalPF(1, 3, PI, 4.0): f(0), f(1), f(1.0), f(3), f(PI), f(float(PI)), f(4), f(4.0)```

Alternatively, the data may be passed as a list:

```f := stats::empiricalPF(1, 3, PI, 4.0): f(0), f(1), f(1.0), f(3), f(PI), f(float(PI)), f(4), f(4.0)```

A symbolic value of the argument in `f` leads to a symbolic return value:

`f(x)`

Symbolic data are not accepted:

`stats::empiricalPF(1, 3, x, 4.0):`
```Error: Unable to convert some of the data to floating-point numbers. [stats::empiricalPF] ```
`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::empiricalPF(s, 2): f(1242), f(1353), f(1200), f(1201)```

`delete s, f:`

### Example 3

We consider a fair die:

`f:= stats::empiricalPF([1, 2, 3, 4, 5, 6]):`

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

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

```f:= stats::empiricalPF([1, 2, 1, 1, 2]): f(1), f(2)```

`delete f:`

## Parameters

 `x1, x2, …` The statistical data: real numerical values `s` A sample of domain type `stats::sample` `c` A column index of the sample `s`: a positive integer. This column provides the data `x1`, `x2` etc. There is no need to specify a column number `c` if the sample has only one non-string column.