Macaulay2 » Documentation
Packages » GraphicalModels :: marginMap
next | previous | forward | backward | up | index | toc

marginMap -- linear map on joint distributions for discrete random variables replacing marginals for indeterminates

Synopsis

Description

The ring $R$ must be a ring of probability distributions on $n$ random variables created using markovRing. The integer $i$ must be in the range from 1 to $n$.

Let $p_{u_1,u_2,\dots, +,\dots,u_n}$ denote the linear form $p_{u_1,u_2,\dots, 1,\dots,u_n} + \dots + p_{u_1,u_2,\dots, d_i,\dots,u_n}$, where $d_i$ is the number of states of random variable $X_i$.

The method marginMap returns a ring map $F : R \to R$ such that after applying $F$, the indeterminate $p_{u_1,u_2,\dots,1,\dots,u_n}$ refers to $ p_{u_1,u_2,\dots, +,\dots,u_n}$, where the '1' and the '$+$' are in the $i$th spot.

Further $F$ is the identity on all other indeterminates, that is, $ F(p_{u_1,u_2,\dots, j,\dots,u_n}) = p_{u_1,u_2,\dots, j,\dots,u_n} $, for all $j\geq 2$.

i1 : F = marginMap(1,markovRing(3,2));

o1 : RingMap QQ[p   ..p   ] <-- QQ[p   ..p   ]
                 1,1   3,2          1,1   3,2
i2 : compactMatrixForm =false;
i3 : transpose F.matrix

o3 = {-1}  |  p    - p    - p     |
           |   1,1    2,1    3,1  |
           |                      |
     {-1}  |  p    - p    - p     |
           |   1,2    2,2    3,2  |
           |                      |
     {-1}  |         p            |
           |          2,1         |
           |                      |
     {-1}  |         p            |
           |          2,2         |
           |                      |
     {-1}  |         p            |
           |          3,1         |
           |                      |
     {-1}  |         p            |
           |          3,2         |

                            6                     1
o3 : Matrix (QQ[p   ..p   ])  <-- (QQ[p   ..p   ])
                 1,1   3,2             1,1   3,2

This linear transformation simplifies ideals and/or polynomials involving $ p_{u_1,u_2,..., +,...,u_n} $. Sometimes, the resulting ideals are toric ideals as the example below shows. For more details see the paper "Algebraic Geometry of Bayesian Networks" by Garcia, Stillman, and Sturmfels.

i4 : G = digraph  {{1,{}},{2,{1}},{3,{1}},{4,{2,3}}}

o4 = Digraph{1 => {}    }
             2 => {1}
             3 => {1}
             4 => {2, 3}

o4 : Digraph
i5 : R = markovRing (2,2,2,2)

o5 = R

o5 : PolynomialRing
i6 : S = globalMarkov G

o6 = {{{1}, {4}, {2, 3}}, {{2}, {3}, {4}}}

o6 : List
i7 : I = conditionalIndependenceIdeal (R,S);

o7 : Ideal of R
i8 : I / print;
- p       p        + p       p
   1,1,1,2 2,1,1,1    1,1,1,1 2,1,1,2
- p       p        + p       p
   1,1,2,2 2,1,2,1    1,1,2,1 2,1,2,2
- p       p        + p       p
   1,2,1,2 2,2,1,1    1,2,1,1 2,2,1,2
- p       p        + p       p
   1,2,2,2 2,2,2,1    1,2,2,1 2,2,2,2
- p       p        + p       p        + p       p        - p       p        - p       p        - p       p        + p       p        + p       p
   1,1,2,1 1,2,1,1    1,1,1,1 1,2,2,1    1,2,2,1 2,1,1,1    1,2,1,1 2,1,2,1    1,1,2,1 2,2,1,1    2,1,2,1 2,2,1,1    1,1,1,1 2,2,2,1    2,1,1,1 2,2,2,1
- p       p        + p       p        + p       p        - p       p        - p       p        - p       p        + p       p        + p       p
   1,1,2,2 1,2,1,2    1,1,1,2 1,2,2,2    1,2,2,2 2,1,1,2    1,2,1,2 2,1,2,2    1,1,2,2 2,2,1,2    2,1,2,2 2,2,1,2    1,1,1,2 2,2,2,2    2,1,1,2 2,2,2,2
i9 : F = marginMap(1,R);

o9 : RingMap R <-- R
i10 : transpose F.matrix

o10 = {-1}  |  p        - p         |
            |   1,1,1,1    2,1,1,1  |
            |                       |
      {-1}  |  p        - p         |
            |   1,1,1,2    2,1,1,2  |
            |                       |
      {-1}  |  p        - p         |
            |   1,1,2,1    2,1,2,1  |
            |                       |
      {-1}  |  p        - p         |
            |   1,1,2,2    2,1,2,2  |
            |                       |
      {-1}  |  p        - p         |
            |   1,2,1,1    2,2,1,1  |
            |                       |
      {-1}  |  p        - p         |
            |   1,2,1,2    2,2,1,2  |
            |                       |
      {-1}  |  p        - p         |
            |   1,2,2,1    2,2,2,1  |
            |                       |
      {-1}  |  p        - p         |
            |   1,2,2,2    2,2,2,2  |
            |                       |
      {-1}  |        p              |
            |         2,1,1,1       |
            |                       |
      {-1}  |        p              |
            |         2,1,1,2       |
            |                       |
      {-1}  |        p              |
            |         2,1,2,1       |
            |                       |
      {-1}  |        p              |
            |         2,1,2,2       |
            |                       |
      {-1}  |        p              |
            |         2,2,1,1       |
            |                       |
      {-1}  |        p              |
            |         2,2,1,2       |
            |                       |
      {-1}  |        p              |
            |         2,2,2,1       |
            |                       |
      {-1}  |        p              |
            |         2,2,2,2       |

              16      1
o10 : Matrix R   <-- R
i11 : J = F I;

o11 : Ideal of R
i12 : J / print;
- p       p        + p       p
   1,1,1,2 2,1,1,1    1,1,1,1 2,1,1,2
- p       p        + p       p
   1,1,2,2 2,1,2,1    1,1,2,1 2,1,2,2
- p       p        + p       p
   1,2,1,2 2,2,1,1    1,2,1,1 2,2,1,2
- p       p        + p       p
   1,2,2,2 2,2,2,1    1,2,2,1 2,2,2,2
- p       p        + p       p
   1,1,2,1 1,2,1,1    1,1,1,1 1,2,2,1
- p       p        + p       p
   1,1,2,2 1,2,1,2    1,1,1,2 1,2,2,2

See also

Ways to use marginMap :

For the programmer

The object marginMap is a method function.