> next up previous contents index
: Access and affectation : Variables: types, sets and : Multiple type variable sets   目次   索引

Variable values

A variable values stores and identifies the values of a variable set $\{V_1, V_2,..., V_n\}$ and is written as $\{V_1=v_1, V_2=v_2,...,
V_n=v_n\}$ where $v_i \in Type(V_i)$ (i.e. $v_i$ is a value in the type of variable $V_i$). As all programming paradigms a Bayesian program needs to store the values of its variables. For example in order to compute the probability of getting two sixes when throwing a couple of dice $P(\{Die_1=6, Die_2=6\}$; or the probability of having a wine quality 4 given that the appellation is ``haut medoc'' and the year is 1989 $P(Quality = 4 \vert Appellation=
\mbox{\lq\lq haut medoc''}, Year=1989)$.

In brief ProBT uses variable values as inputs and outputs parameters for methods such as compute, draw or best, briefly introduced in the previous chapter. Variable values are represented by the object class plValues and constructed by a variable set. When a plValues is created its values are initialized with the first value of the variable types. For example, consider the following statements:

  //Defining types for year, quality and price
  plIntegerType year_type(1800, 2002);
  plIntegerType quality_type(1, 5);
  plRealType    price_type(15.5, 7000);

  //Defining variables of types year, quality and price
  plSymbol year("year", year_type);
  plSymbol quality("quality", quality_type);
  plSymbol price("price", price_type);

  //Defining a variable values storing values of year, quality and price
  plValues wine(year^quality^price);

  cout<<"wine = "<<wine<<"\n";

the output shows:

wine = {year=1800 quality=1 price=15.5}




next up previous contents index
: Access and affectation : Variables: types, sets and : Multiple type variable sets   目次   索引
Juan-Manuel Ahuactzin 平成17年3月31日