gfn.gym.helpers.bayesian_structure.graph ======================================== .. py:module:: gfn.gym.helpers.bayesian_structure.graph Functions --------- .. autoapisummary:: gfn.gym.helpers.bayesian_structure.graph.sample_erdos_renyi_graph gfn.gym.helpers.bayesian_structure.graph.sample_erdos_renyi_linear_gaussian Module Contents --------------- .. py:function:: sample_erdos_renyi_graph(num_nodes, rng, p = None, num_edges = None, node_names = None) Sample an Erdos-Renyi graph. :param num_nodes: Number of nodes in the graph. :param rng: Numpy random number generator. :param p: Probability of creating an edge. :param num_edges: Total number of edges (used to compute p if p is None). :param node_names: Optional list of node names. :returns: A PyTorch Geometric Data object representing the sampled graph with an attribute 'node_names' mapping indices to node names. :rtype: Data :raises ValueError: If both p and num_edges are None. .. py:function:: sample_erdos_renyi_linear_gaussian(num_nodes, rng, p = None, num_edges = None, node_names = None, loc_edges = 0.0, scale_edges = 1.0, obs_noise = 0.1) Sample a linear Gaussian Bayesian network based on an Erdos-Renyi graph. Creates graph structure using torch-geometric and assigns CPD factors for each node. Each CPD factor is constructed by sampling a parameter vector theta (with bias fixed to zero) based on the node's parent set determined from the graph structure. :param num_nodes: Number of nodes. :param rng: Random number generator for reproducibility. :param p: Probability of creating an edge. :param num_edges: Total number of edges (used to compute p if p is None). :param node_names: Optional list of node names. :param loc_edges: Mean value for edge parameters. :param scale_edges: Standard deviation for edge parameters. :param obs_noise: Observation noise for each node. :returns: A PyTorch Geometric Data object with additional attributes 'nodes' and 'cpds'. 'nodes' is a list of node names. 'cpds' contains a list of LinearGaussianCPD factors for each node. :rtype: Data