0
# Discrete Distributions
1
2
Discrete probability distributions for modeling categorical and binary outcomes, including various parameterizations for different use cases.
3
4
## Capabilities
5
6
### Bernoulli Distribution
7
8
Binary distribution for modeling binary outcomes.
9
10
```python { .api }
11
class Bernoulli(Distribution):
12
def __init__(self, logits=None, probs=None, dtype=int):
13
"""
14
Bernoulli distribution for binary outcomes.
15
16
Parameters:
17
- logits: log-odds parameter (float or array, mutually exclusive with probs)
18
- probs: probability parameter (float or array in [0,1], mutually exclusive with logits)
19
- dtype: output data type (int or float)
20
21
Note: Exactly one of logits or probs must be specified.
22
"""
23
24
@property
25
def logits(self): ...
26
@property
27
def probs(self): ...
28
@property
29
def dtype(self): ...
30
@property
31
def event_shape(self): ...
32
```
33
34
### Categorical Distribution
35
36
Categorical distribution for discrete outcomes with multiple categories.
37
38
```python { .api }
39
class Categorical(Distribution):
40
def __init__(self, logits=None, probs=None, dtype=int):
41
"""
42
Categorical distribution for discrete outcomes.
43
44
Parameters:
45
- logits: log-probabilities (array of shape [..., k], mutually exclusive with probs)
46
- probs: probabilities (array of shape [..., k] that sums to 1, mutually exclusive with logits)
47
- dtype: output data type (int or float)
48
49
Note: Exactly one of logits or probs must be specified.
50
"""
51
52
@property
53
def logits(self): ...
54
@property
55
def probs(self): ...
56
@property
57
def dtype(self): ...
58
@property
59
def num_categories(self): ...
60
@property
61
def event_shape(self): ...
62
```
63
64
### One-Hot Categorical Distribution
65
66
Categorical distribution with one-hot encoded outcomes.
67
68
```python { .api }
69
class OneHotCategorical(Distribution):
70
def __init__(self, logits=None, probs=None, dtype=float):
71
"""
72
One-hot categorical distribution.
73
74
Parameters:
75
- logits: log-probabilities (array of shape [..., k], mutually exclusive with probs)
76
- probs: probabilities (array of shape [..., k] that sums to 1, mutually exclusive with logits)
77
- dtype: output data type (float or int)
78
79
Note: Exactly one of logits or probs must be specified.
80
"""
81
82
@property
83
def logits(self): ...
84
@property
85
def probs(self): ...
86
@property
87
def dtype(self): ...
88
@property
89
def num_categories(self): ...
90
@property
91
def event_shape(self): ...
92
```
93
94
### Categorical Uniform Distribution
95
96
Uniform categorical distribution over all categories.
97
98
```python { .api }
99
class CategoricalUniform(Distribution):
100
def __init__(self, num_categories, dtype=int):
101
"""
102
Uniform categorical distribution.
103
104
Parameters:
105
- num_categories: number of categories (positive integer)
106
- dtype: output data type (int or float)
107
"""
108
109
@property
110
def num_categories(self): ...
111
@property
112
def dtype(self): ...
113
@property
114
def logits(self): ...
115
@property
116
def probs(self): ...
117
```
118
119
### Multinomial Distribution
120
121
Multinomial distribution for modeling counts across multiple categories.
122
123
```python { .api }
124
class Multinomial(Distribution):
125
def __init__(self, total_count, logits=None, probs=None, dtype=int):
126
"""
127
Multinomial distribution.
128
129
Parameters:
130
- total_count: total number of trials (positive integer or array)
131
- logits: log-probabilities for each category (array, mutually exclusive with probs)
132
- probs: probabilities for each category (array that sums to 1, mutually exclusive with logits)
133
- dtype: output data type (int or float)
134
135
Note: Exactly one of logits or probs must be specified.
136
"""
137
138
@property
139
def total_count(self): ...
140
@property
141
def logits(self): ...
142
@property
143
def probs(self): ...
144
@property
145
def event_shape(self): ...
146
```
147
148
### Softmax Distribution
149
150
Softmax distribution for normalized discrete outcomes.
151
152
```python { .api }
153
class Softmax(Distribution):
154
def __init__(self, logits, temperature=1.0):
155
"""
156
Softmax distribution.
157
158
Parameters:
159
- logits: unnormalized log-probabilities (array of shape [..., k])
160
- temperature: temperature parameter for softmax (positive float, default 1.0)
161
"""
162
163
@property
164
def logits(self): ...
165
@property
166
def temperature(self): ...
167
@property
168
def probs(self): ...
169
```