class_docstr: Initializes the Approximate Inference class.
  
  Parameters
  ----------
  model: Instance of pgmpy.models.BayesianNetwork or pgmpy.models.DynamicBayesianNetwork
  
  Examples
  --------
  >>> from pgmpy.utils import get_example_model
  >>> model = get_example_model('alarm')
  >>> infer = ApproxInference(model)
docstr: Computes distribution of `variables` from given data `samples`.
  
  Parameters
  ----------
  samples: pandas.DataFrame
      A dataframe of samples generated from the model.
  
  variables: list (array-like)
      A list of variables whose distribution needs to be computed.
  
  state_names: dict (default: None)
      A dict of state names for each variable in `variables` in the form {variable_name: list of states}.
      If None, inferred from the data but is possible that the final distribution misses some states.
  
  joint: boolean
      If joint=True, computes the joint distribution over `variables`.
      Else, returns a dict with marginal distribution of each variable in
      `variables`.
code: def get_distribution(
      self, samples, variables, state_names=None, joint=True
  ):
      """
      Computes distribution of `variables` from given data `samples`.
  
      Parameters
      ----------
      samples: pandas.DataFrame
          A dataframe of samples generated from the model.
  
      variables: list (array-like)
          A list of variables whose distribution needs to be computed.
  
      state_names: dict (default: None)
          A dict of state names for each variable in `variables` in the form {variable_name: list of states}.
          If None, inferred from the data but is possible that the final distribution misses some states.
  
      joint: boolean
          If joint=True, computes the joint distribution over `variables`.
          Else, returns a dict with marginal distribution of each variable in
          `variables`.
      """
      if joint == True:
          return self._get_factor_from_df(
              samples.groupby(variables).size() / samples.shape[0],
              state_names,
          )
      else:
          return {
              var: self._get_factor_from_df(
                  samples.groupby([var]).size() / samples.shape[0],
                  state_names,
              )
              for var in variables
          }
  
file_path: pgmpy/pgmpy/inference/ApproxInference.py
imports: import itertools
  from pgmpy.factors.discrete import DiscreteFactor
  from pgmpy.models import BayesianNetwork, DynamicBayesianNetwork
label_desc: Use image node_id 3 for calling the ApproxInference obj's underlying member method code with example usage: obj.get_distribution(samples, variables, state_names, joint) and returns: self, unknown