class_docstr: univariate mixture distribution
  
  for simple case for now (unbound support)
  does not yet inherit from scipy.stats.distributions
  
  adding pdf to mixture_rvs, some restrictions on broadcasting
  Currently it does not hold any state, all arguments included in each method.
docstr: pdf a mixture of distributions.
  
  Parameters
  ----------
  x : array_like
      Array containing locations where the PDF should be evaluated
  prob : array_like
      Probability of sampling from each distribution in dist
  dist : array_like
      An iterable of distributions objects from scipy.stats.
  kwargs : tuple of dicts, optional
      A tuple of dicts.  Each dict in kwargs can have keys loc, scale, and
      args to be passed to the respective distribution in dist.  If not
      provided, the distribution defaults are used.
  
  Examples
  --------
  Say we want 5000 random variables from mixture of normals with two
  distributions norm(-1,.5) and norm(1,.5) and we want to sample from the
  first with probability .75 and the second with probability .25.
  
  >>> import numpy as np
  >>> from scipy import stats
  >>> from statsmodels.distributions.mixture_rvs import MixtureDistribution
  >>> x = np.arange(-4.0, 4.0, 0.01)
  >>> prob = [.75,.25]
  >>> mixture = MixtureDistribution()
  >>> Y = mixture.pdf(x, prob, dist=[stats.norm, stats.norm],
  ...                 kwargs = (dict(loc=-1,scale=.5),dict(loc=1,scale=.5)))
docstr_tok: ["pdf","a","mixture","of","distributions",".","Parameters","--","--","--","--","--","x",":","array_like","Array","containing","locations","where","the","PDF","should","be","evaluated","prob",":","array_like","Probability","of","sampling","from","each","distribution","in","dist","dist",":","array_like","An","iterable","of","distributions","objects","from","scipy.stats",".","kwargs",":","tuple","of","dicts",",","optional","A","tuple","of","dicts",".","Each","dict","in","kwargs","can","have","keys","loc",",","scale",",","and","args","to","be","passed","to","the","respective","distribution","in","dist",".","If","not","provided",",","the","distribution","defaults","are","used",".","Examples","--","--","--","--","Say","we","want","5000","random","variables","from","mixture","of","normals","with","two","distributions","norm","(","-1",",",".5",")","and","norm","(","1",",",".5",")","and","we","want","to","sample","from","the","first","with","probability",".75","and","the","second","with","probability",".25",".",">",">",">","import","numpy","as","np",">",">",">","from","scipy","import","stats",">",">",">","from","statsmodels.distributions.mixture_rvs","import","MixtureDistribution",">",">",">","x","=","np.arange","(","-4.0",",","4.0",",","0.01",")",">",">",">","prob","=","[",".75",",",".25","]",">",">",">","mixture","=","MixtureDistribution","(",")",">",">",">","Y","=","mixture.pdf","(","x",",","prob",",","dist=","[","stats.norm",",","stats.norm","]",",","...","kwargs","=","(","dict","(","loc=-1",",","scale=.5",")",",","dict","(","loc=1",",","scale=.5",")",")",")"]
code: def pdf(self, x, prob, dist, kwargs=None):
      """
      pdf a mixture of distributions.
  
      Parameters
      ----------
      x : array_like
          Array containing locations where the PDF should be evaluated
      prob : array_like
          Probability of sampling from each distribution in dist
      dist : array_like
          An iterable of distributions objects from scipy.stats.
      kwargs : tuple of dicts, optional
          A tuple of dicts.  Each dict in kwargs can have keys loc, scale, and
          args to be passed to the respective distribution in dist.  If not
          provided, the distribution defaults are used.
  
      Examples
      --------
      Say we want 5000 random variables from mixture of normals with two
      distributions norm(-1,.5) and norm(1,.5) and we want to sample from the
      first with probability .75 and the second with probability .25.
  
      >>> import numpy as np
      >>> from scipy import stats
      >>> from statsmodels.distributions.mixture_rvs import MixtureDistribution
      >>> x = np.arange(-4.0, 4.0, 0.01)
      >>> prob = [.75,.25]
      >>> mixture = MixtureDistribution()
      >>> Y = mixture.pdf(x, prob, dist=[stats.norm, stats.norm],
      ...                 kwargs = (dict(loc=-1,scale=.5),dict(loc=1,scale=.5)))
      """
      if len(prob) != len(dist):
          raise ValueError(
              "You must provide as many probabilities as distributions"
          )
      if not np.allclose(np.sum(prob), 1):
          raise ValueError("prob does not sum to 1")
  
      if kwargs is None:
          kwargs = ({},) * len(prob)
  
      for i in range(len(prob)):
          loc = kwargs[i].get("loc", 0)
          scale = kwargs[i].get("scale", 1)
          args = kwargs[i].get("args", ())
          if i == 0:  # assume all broadcast the same as the first dist
              pdf_ = prob[i] * dist[i].pdf(
                  x, *args, loc=loc, scale=scale
              )
          else:
              pdf_ += prob[i] * dist[i].pdf(
                  x, *args, loc=loc, scale=scale
              )
      return pdf_
  
file_path: statsmodels/statsmodels/distributions/mixture_rvs.py
imports: import numpy
label_desc: Use image node_id 2 for calling the MixtureDistribution obj's underlying member method code with example usage: obj.pdf(x, prob, dist, kwargs) and returns: pdf_