# Aggregators

Aggregators are special type of nodes that includes a generic CPT for any numbers of parents.

pyAgrum proposes a list of such aggregators. Some of then are used below.

In [1]:

import numpy as np

import pyAgrum as gum
import pyAgrum.lib.notebook as gnb

In [2]:

min_x=0
max_x=15

bn=gum.BayesNet()

gum.config['notebook','histogram_line_threshold']=15

In [3]:

nmax=bn.addMAX(gum.RangeVariable("MAX","MAX",min_x,max_x))

for n in [l[0],l[1],l[2],l[3]]:
#potential for median has a size : 16^5=2^20 double !


In [4]:

for nod in l:
bn.cpt(nod).fillWith(1).normalize()
gnb.showInference(bn,size="13")

In [5]:

gnb.showInference(bn,size="13",evs={'MEDIAN':[0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0]})

In [6]:

# if the roots do not have uniform but random distribution
for nod in l:
bn.generateCPT(nod)

gnb.showInference(bn,size="13")

In [7]:

gnb.showInference(bn,size="13",evs={'MEDIAN':[0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0]})

In [ ]: