## Introduction

C++ for embedded systems, or CES for short, is a language extension for

C++, designed for

probabilistic algorithms, mainly in the field of

AI. This is needed, because all

sensor based systems, e.g. robots, have to deal with

uncertainty.

## Probabilistic Data Types

Probability distributions are defined over a set of variables. If the

event space is

`type`

, then the template

`prob<type>`

defines a distribution over

`type`

. CES offers four ways of creating probability distributions. These are:

**1. Enumeration.** a distribution can be set by a list in the format:

`{ {v1, p1}, {v2, p2}, ..., {vN, pN} }`

**2. Type conversion.** a point mass distribution, where all the probability is centred on one point, can be created using

`type x;`

prob = x;

which makes a point mass distribution on x.

**3. Library.** probability distributions are offered via library functions, e.g.

`x = NORMAL1D(0.0, 1.0);`

assigned a normal distribution, between 0 and 1 to x.

**4. Probloop.** complex probability distributions can be created by using the probloop function, which will be explained later.

Type conversion from prob to type will assign the

expected value of the probability distribution.

## Arithmetic Operators

All the arithmetic operators in C++ are applicable to probability distributions, but as distributions are more complex, their is often more than one way to

interpret them. e.g.

`z = prob<int> * prob<int>;`

can be interpreted as two

random variables being multiplied, or, two distributions over the same event space. To help illustrate this, say we have two distributions,

```
x = {{1, 0.2}, {2, 0.8}};
y = {{1, 0.5}, {2, 0.5}};
```

In the first interpretation, where x and y are

independent events,

```
z = {{1, 0.2*0.5}, {2, (0.8*0.5) + (0.2*0.5)}, {4, 0.8*0.5}};
z = {{1, 0.1}, {2, 0.5}, {4, 0.4}};
```

in the second interpretation, where x and y are distributions over the same space, so they must take the same value at all times:

```
z = {{1, 0.2*0.5}, {4, 0.8*0.5}};
after normalization,
z = {{1, 0.2}, {2, 0.8}};
```

## Probloop

The probloop

command is of the form

```
probloop(X1,...,Xn; Y1,...,Ym)
{
//statements
}
```

Where

statements implements a

function f, and x1 - xN are input variables, and y1 through yM are output variables of f. All of these variables must be probabilistic, though not necessarily of the same type. Inside the

loop, however, these variables are reduced to their non-probabilistic base type.

The specification can be found here