*Bounty: 50*

*Bounty: 50*

These are the relations defined in the graph.

P(D),

P(E),

P(A),

P(C),

P(G|D, E, A),

P(I|E, A, C),

P(T|E, C),

P(F|E, A, C),

P(S|A),

P(J|G, I)

Hello, I have this network that shows a graph (Graphical model). The directed edges represent conditional probabilities. I need to compute a number of parameters for this whole graph. I know the formulas K – 1 where K is the number of states or K^M – 1 when I have M variables. The problem here is that the number of states each node can assume is different.

Here are the number of states each random variable can have.

```
[('Difficulty', 'D', 3), ('Effort', 'E', 3), ('Aptitute', 'A', 5), ('Confidence', 'C', 3), ('Grade', 'G', 5), ('Interview', 'I', 3), ('TuteAttendence', 'T', 3), ('ForumParticipation', 'F', 3), ('SAT', 'S', 3), ('Job', 'J', 2)]
```

How to compute a total number of parameters this model needs when fully connected vs when the DAG is considered.

I have made a python function that computes it as follows.

```
def calculate_params(n):
n_states = len(n.states)
if len(n.parents) == 0:
return n_states
else:
p_states = []
for p in n.parents:
p_states.append(calculate_params(p) - 1)
return (n_states - 1) * np.prod(np.asarray(p_states))
print(calculate_params(J))
```

it outputs 1923. Is this answer correct?

Also how to compute the number of parameters when the graph is fully connected. In my opinion it should be `print((3**7 - 1) + (5**2) + (2**1 - 1)) = 2212 `

but I am not sure.

What would be an easy correct way to compute this?