# AverageLink

The **AverageLink** is used to take the weighted average of a predicate over all of its arguments. It inherits from LambdaLink (or ScopeLink, TBD), and explicitly binds one or more variables; the bound variables are the ones over which the average is taken.

## Structure

The AverageLink has the structure of:

AverageLink <TV> X P(X)

Where X can be a variable of a list of variable and P is a predicate.

## PLN Semantics

Averages are usually understood to be taken over contexts; in the probabilistic interpretation, they are weighted averages. See ContextLink for more information.

Because, in a certain sense, free variables do not make sense in PLN, expressions containing free variables are always interpreted as if those variables were bound by an implicit AverageLink.

TV is calculated as follows

TV.s = Sum_X X.TV.s * P(X).TV.s / Sum_X X.TV.s

The confidence of TV should also be appropriately calculated by considering the distribution of TVs of its arguments, but that is not yet the case.

Note that this is actually equivalent to

P(X) <TV>

That is, by default, the TV of a predicate is interpreted as if it were wrapped into an AverageLink over all its variables.

## Example

The EvaluationLink below contains a free variable $X

(EvaluationLink (stv 0.1 0.9) (PredicateNode "breathe") (ListLink (VariableNode "$X") (ConceptNode "air") ) )

It will be interpreted by PLN as being equivalent to

(AverageLink (stv 0.1 0.9) (VariableNode "$X") (EvaluationLink (PredicateNode "breathe") (ListLink (VariableNode "$X") (ConceptNode "air") ) ) )

which states that "on average, with confidence 0.9, 10% of everything breathes air".

### General quantification

If the quantification is general, as in

(AverageLink (stv 0.15 0.9) (VariableNode "$X") (EvaluationLink (PredicateNode "breathe") (VariableNode "$X") ) )

that is $X is not restricted to a particular pattern, then the TV on the AverageLink corresponds to the one on the PredicateNode, that is

(PredicateNode "breathe" (stv 0.15 0.9))

stating that "on average, with confidence 0.9, 15% of everything breathes". Addtional discusson of this can be found on the ContextLink page, and in section 10.7.1 of the PLN book.