예제 #1
0
    def dirichlet(self,
                  name,
                  alpha,
                  n_samples=None,
                  group_ndims=0,
                  check_numerics=False,
                  **kwargs):
        """
        Add a stochastic node in this :class:`BayesianNet` that follows the
        Dirichlet distribution.

        :param name: The name of the stochastic node. Must be unique in a
            :class:`BayesianNet`.

        See
        :class:`~zhusuan.distributions.multivariate.Dirichlet`
        for more information about the other arguments.

        :return: A :class:`StochasticTensor` instance.
        """
        dist = distributions.Dirichlet(alpha,
                                       group_ndims=group_ndims,
                                       check_numerics=check_numerics,
                                       **kwargs)
        return self.stochastic(name, dist, n_samples=n_samples, **kwargs)
예제 #2
0
 def __init__(self,
              name,
              alpha,
              n_samples=None,
              group_ndims=0,
              check_numerics=False,
              **kwargs):
     dirichlet = distributions.Dirichlet(alpha,
                                         group_ndims=group_ndims,
                                         check_numerics=check_numerics,
                                         **kwargs)
     super(Dirichlet, self).__init__(name, dirichlet, n_samples)