2.2.1.2. pywhy_graphs.functional.discrete.add_cpd_for_node#
- pywhy_graphs.functional.discrete.add_cpd_for_node(G: DiGraph, node, cpd: TabularCPD, noise_ratio: float = 0.0, random_state=None, overwrite: bool = False)[source]#
Add CPD (Conditional Probability Distribution) to graph.
This is a wrapper around a similar function as BayesianNetwork.add_cpds. Adds a conditional probability distribution table for each node, which is defines conditional probabilities for that node given its parents’ states.
- Parameters:
- GGraph
The causal graph.
- nodeNode
A node in G.
- cpdTabularCPD
CPDs which will be associated with this node.
- noise_ratiofloat
The ratio of the times the noise function is applied to sample the node. By default, the exogenous distribution is defined as a uniform distribution over all possible values of the node. If noise_ratio is set to 0.1, then 10% of the time the exogenous distribution is applied, and 90% of the time the parent function is applied.
- random_staterandom number generator, optional
The random number generator, by default None.
- overwritebool, optional
Whether to overwrite an existing CPD for the node, by default False.