

def marginal_distribution(self, variables, inplace=True):
    "\n        Returns the marginal distribution over variables.\n\n        Parameters\n        ----------\n        variables: string, list, tuple, set, dict\n                Variable or list of variables over which marginal distribution needs\n                to be calculated\n        inplace: Boolean (default True)\n                If False return a new instance of JointProbabilityDistribution\n\n        Examples\n        --------\n        >>> import numpy as np\n        >>> from pgmpy.factors import JointProbabilityDistribution\n        >>> values = np.random.rand(12)\n        >>> prob = JointProbabilityDistribution(['x1', 'x2', 'x3'], [2, 3, 2], values/np.sum(values))\n        >>> prob.marginal_distribution(['x1', 'x2'])\n        >>> print(prob)\n        x1    x2      P(x1,x2)\n        ----  ----  ----------\n        x1_0  x2_0      0.1502\n        x1_0  x2_1      0.1626\n        x1_0  x2_2      0.1197\n        x1_1  x2_0      0.2339\n        x1_1  x2_1      0.1996\n        x1_1  x2_2      0.1340\n        "
    return variables.marginalize(list((set(list(self.variables)) - set((variables if isinstance(variables, (list, set, dict, tuple)) else [variables])))), inplace=inplace)

dataset/ETHPy150Open pgmpy/pgmpy/pgmpy/factors/JointProbabilityDistribution.py JointProbabilityDistribution.marginal_distribution/VarMisuse@19/393 `self`->`variables`