Class DirichletSampler

    • Method Detail

      • sample

        public double[] sample()
        Create an object sample.
        Specified by:
        sample in interface ObjectSampler<double[]>
        Returns:
        a sample.
      • getK

        protected abstract int getK()
        Gets the number of categories.
        Returns:
        k
      • nextGamma

        protected abstract double nextGamma​(int category)
        Create a gamma sample for the given category.
        Parameters:
        category - Category.
        Returns:
        the sample
      • of

        public static DirichletSampler of​(UniformRandomProvider rng,
                                          double... alpha)
        Creates a new Dirichlet distribution sampler.
        Parameters:
        rng - Generator of uniformly distributed random numbers.
        alpha - Concentration parameters.
        Returns:
        the sampler
        Throws:
        IllegalArgumentException - if the number of concentration parameters is less than 2; or if any concentration parameter is not strictly positive.
      • symmetric

        public static DirichletSampler symmetric​(UniformRandomProvider rng,
                                                 int k,
                                                 double alpha)
        Creates a new symmetric Dirichlet distribution sampler using the same concentration parameter for each category.
        Parameters:
        rng - Generator of uniformly distributed random numbers.
        k - Number of categories.
        alpha - Concentration parameter.
        Returns:
        the sampler
        Throws:
        IllegalArgumentException - if the number of categories is less than 2; or if the concentration parameter is not strictly positive.