Multinomial¶
- class paddle.distribution. Multinomial ( total_count, probs ) [source]
- 
         Multinomial distribution parameterized by total_countandprobs.In probability theory, the multinomial distribution is a generalization of the binomial distribution, it models the probability of counts for each side of a k-sided die rolled n times. When k is 2 and n is 1, the multinomial is the bernoulli distribution, when k is 2 and n is grater than 1, it is the binomial distribution, when k is grater than 2 and n is 1, it is the categorical distribution. The probability mass function (PMF) for multinomial is \[f(x_1, ..., x_k; n, p_1,...,p_k) = \frac{n!}{x_1!...x_k!}p_1^{x_1}...p_k^{x_k}\]where, \(n\) is number of trials, k is the number of categories, \(p_i\) denote probability of a trial falling into each category, \({\textstyle \sum_{i=1}^{k}p_i=1}, p_i \ge 0\), and \(x_i\) denote count of each category. - Parameters
- 
           - total_count (int) – Number of trials. 
- probs (Tensor) – Probability of a trial falling into each category. Last axis of probs indexes over categories, other axes index over batches. Probs value should between [0, 1], and sum to 1 along last axis. If the value over 1, it will be normalized to sum to 1 along the last axis. 
 
 Examples: import paddle multinomial = paddle.distribution.Multinomial(10, paddle.to_tensor([0.2, 0.3, 0.5])) print(multinomial.sample((2, 3))) # Tensor(shape=[2, 3, 3], dtype=float32, place=Place(gpu:0), stop_gradient=True, # [[[1., 4., 5.], # [0., 2., 8.], # [2., 4., 4.]], # [[1., 6., 3.], # [3., 3., 4.], # [3., 4., 3.]]]) - 
            
           probs
           (
           value
           )
           probs¶
- 
           Probability density/mass function. Note This method will be deprecated in the future, please use prob instead. 
 - property mean
- 
           mean of multinomial distribuion. - Returns
- 
             mean value. 
- Return type
- 
             Tensor 
 
 - property variance
- 
           variance of multinomial distribution. - Returns
- 
             variance value. 
- Return type
- 
             Tensor 
 
 - 
            
           prob
           (
           value
           )
           prob¶
- 
           probability mass function evaluated at value. - Parameters
- 
             value (Tensor) – value to be evaluated. 
- Returns
- 
             probability of value. 
- Return type
- 
             Tensor 
 
 - 
            
           log_prob
           (
           value
           )
           log_prob¶
- 
           probability mass function evaluated at value - Parameters
- 
             value (Tensor) – value to be evaluated. 
- Returns
- 
             probability of value. 
- Return type
- 
             Tensor 
 
 - 
            
           sample
           (
           shape=()
           )
           sample¶
- 
           draw sample data from multinomial distribution - Parameters
- 
             sample_shape (tuple, optional) – [description]. Defaults to (). 
 
 - 
            
           entropy
           (
           )
           entropy¶
- 
           entropy of multinomial distribution - Returns
- 
             entropy value 
- Return type
- 
             Tensor 
 
 - property batch_shape
- 
           Returns batch shape of distribution - Returns
- 
             batch shape 
- Return type
- 
             Sequence[int] 
 
 - property event_shape
- 
           Returns event shape of distribution - Returns
- 
             event shape 
- Return type
- 
             Sequence[int] 
 
 - 
            
           kl_divergence
           (
           other
           )
           [source]
           kl_divergence¶
- 
           The KL-divergence between self distributions and other. 
 - 
            
           rsample
           (
           shape=()
           )
           rsample¶
- 
           reparameterized sample 
 
