class_docstr: Base class for Joint Probability Distribution
class_docstr_tok: ["Base","class","for","Joint","Probability","Distribution"]
docstr: Checks whether the given BayesianNetwork is Imap of JointProbabilityDistribution
  
  Parameters
  ----------
  model : An instance of BayesianNetwork Class, for which you want to
      check the Imap
  
  Returns
  -------
  Is IMAP: bool
      True if given Bayesian Network is Imap for Joint Probability Distribution False otherwise
  
  Examples
  --------
  >>> from pgmpy.models import BayesianNetwork
  >>> from pgmpy.factors.discrete import TabularCPD
  >>> from pgmpy.factors.discrete import JointProbabilityDistribution
  >>> bm = BayesianNetwork([('diff', 'grade'), ('intel', 'grade')])
  >>> diff_cpd = TabularCPD('diff', 2, [[0.2], [0.8]])
  >>> intel_cpd = TabularCPD('intel', 3, [[0.5], [0.3], [0.2]])
  >>> grade_cpd = TabularCPD('grade', 3,
  ...                        [[0.1,0.1,0.1,0.1,0.1,0.1],
  ...                         [0.1,0.1,0.1,0.1,0.1,0.1],
  ...                         [0.8,0.8,0.8,0.8,0.8,0.8]],
  ...                        evidence=['diff', 'intel'],
  ...                        evidence_card=[2, 3])
  >>> bm.add_cpds(diff_cpd, intel_cpd, grade_cpd)
  >>> val = [0.01, 0.01, 0.08, 0.006, 0.006, 0.048, 0.004, 0.004, 0.032,
  ...        0.04, 0.04, 0.32, 0.024, 0.024, 0.192, 0.016, 0.016, 0.128]
  >>> JPD = JointProbabilityDistribution(['diff', 'intel', 'grade'], [2, 3, 3], val)
  >>> JPD.is_imap(bm)
  True
docstr_tok: ["Checks","whether","the","given","BayesianNetwork","is","Imap","of","JointProbabilityDistribution","Parameters","--","--","--","--","--","model",":","An","instance","of","BayesianNetwork","Class",",","for","which","you","want","to","check","the","Imap","Returns","--","--","--","-","Is","IMAP",":","bool","True","if","given","Bayesian","Network","is","Imap","for","Joint","Probability","Distribution","False","otherwise","Examples","--","--","--","--",">",">",">","from","pgmpy.models","import","BayesianNetwork",">",">",">","from","pgmpy.factors.discrete","import","TabularCPD",">",">",">","from","pgmpy.factors.discrete","import","JointProbabilityDistribution",">",">",">","bm","=","BayesianNetwork","(","[","(","'diff","'",",","'grade","'",")",",","(","'intel","'",",","'grade","'",")","]",")",">",">",">","diff_cpd","=","TabularCPD","(","'diff","'",",","2",",","[","[","0.2","]",",","[","0.8","]","]",")",">",">",">","intel_cpd","=","TabularCPD","(","'intel","'",",","3",",","[","[","0.5","]",",","[","0.3","]",",","[","0.2","]","]",")",">",">",">","grade_cpd","=","TabularCPD","(","'grade","'",",","3",",","...","[","[","0.1,0.1,0.1,0.1,0.1,0.1","]",",","...","[","0.1,0.1,0.1,0.1,0.1,0.1","]",",","...","[","0.8,0.8,0.8,0.8,0.8,0.8","]","]",",","...","evidence=","[","'diff","'",",","'intel","'","]",",","...","evidence_card=","[","2",",","3","]",")",">",">",">","bm.add_cpds","(","diff_cpd",",","intel_cpd",",","grade_cpd",")",">",">",">","val","=","[","0.01",",","0.01",",","0.08",",","0.006",",","0.006",",","0.048",",","0.004",",","0.004",",","0.032",",","...","0.04",",","0.04",",","0.32",",","0.024",",","0.024",",","0.192",",","0.016",",","0.016",",","0.128","]",">",">",">","JPD","=","JointProbabilityDistribution","(","[","'diff","'",",","'intel","'",",","'grade","'","]",",","[","2",",","3",",","3","]",",","val",")",">",">",">","JPD.is_imap","(","bm",")","True"]
code: def is_imap(self, model):
      """
      Checks whether the given BayesianNetwork is Imap of JointProbabilityDistribution
  
      Parameters
      ----------
      model : An instance of BayesianNetwork Class, for which you want to
          check the Imap
  
      Returns
      -------
      Is IMAP: bool
          True if given Bayesian Network is Imap for Joint Probability Distribution False otherwise
  
      Examples
      --------
      >>> from pgmpy.models import BayesianNetwork
      >>> from pgmpy.factors.discrete import TabularCPD
      >>> from pgmpy.factors.discrete import JointProbabilityDistribution
      >>> bm = BayesianNetwork([('diff', 'grade'), ('intel', 'grade')])
      >>> diff_cpd = TabularCPD('diff', 2, [[0.2], [0.8]])
      >>> intel_cpd = TabularCPD('intel', 3, [[0.5], [0.3], [0.2]])
      >>> grade_cpd = TabularCPD('grade', 3,
      ...                        [[0.1,0.1,0.1,0.1,0.1,0.1],
      ...                         [0.1,0.1,0.1,0.1,0.1,0.1],
      ...                         [0.8,0.8,0.8,0.8,0.8,0.8]],
      ...                        evidence=['diff', 'intel'],
      ...                        evidence_card=[2, 3])
      >>> bm.add_cpds(diff_cpd, intel_cpd, grade_cpd)
      >>> val = [0.01, 0.01, 0.08, 0.006, 0.006, 0.048, 0.004, 0.004, 0.032,
      ...        0.04, 0.04, 0.32, 0.024, 0.024, 0.192, 0.016, 0.016, 0.128]
      >>> JPD = JointProbabilityDistribution(['diff', 'intel', 'grade'], [2, 3, 3], val)
      >>> JPD.is_imap(bm)
      True
      """
      from pgmpy.models import BayesianNetwork
  
      if not isinstance(model, BayesianNetwork):
          raise TypeError(
              "model must be an instance of BayesianNetwork"
          )
      factors = [cpd.to_factor() for cpd in model.get_cpds()]
      factor_prod = reduce(mul, factors)
      JPD_fact = DiscreteFactor(
          self.variables, self.cardinality, self.values
      )
      if JPD_fact == factor_prod:
          return True
      else:
          return False
  
file_path: pgmpy/pgmpy/factors/discrete/JointProbabilityDistribution.py
imports: import itertools
  from functools import reduce
  from operator import mul
  import numpy
  from pgmpy.factors.discrete import DiscreteFactor
  from pgmpy.independencies import Independencies
label_desc: Use image node_id 10 for calling the JointProbabilityDistribution obj's underlying member method code with example usage: obj.is_imap(model) and returns: True, False