Spaces:
Sleeping
Sleeping
AdditionalDistributions
#1
by
kalpshah18 - opened
- config/continuous/gamma.py +11 -0
- config/continuous/laplace.py +11 -0
- config/discrete/categorical.py +10 -0
config/continuous/gamma.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import torch
|
| 3 |
+
|
| 4 |
+
GAMMA = {
|
| 5 |
+
"params": lambda: {
|
| 6 |
+
"alpha": st.sidebar.slider("Alpha (α)", 0.1, 10.0, 2.0, 0.1),
|
| 7 |
+
"beta": st.sidebar.slider("Beta (β)", 0.1, 10.0, 2.0, 0.1),
|
| 8 |
+
},
|
| 9 |
+
"dist": lambda p: torch.distributions.Gamma(p["alpha"], p["beta"]),
|
| 10 |
+
"support": lambda p: (0, None),
|
| 11 |
+
}
|
config/continuous/laplace.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import torch
|
| 3 |
+
|
| 4 |
+
LAPLACE = {
|
| 5 |
+
"params": lambda: {
|
| 6 |
+
"mean": st.sidebar.slider("Mean (μ)", -10.0, 10.0, 0.0),
|
| 7 |
+
"scale": st.sidebar.slider("Scale (λ)", 0.1, 10.0, 1.0),
|
| 8 |
+
},
|
| 9 |
+
"dist": lambda p: torch.distributions.Laplace(p["mean"], p["scale"]),
|
| 10 |
+
"support": None,
|
| 11 |
+
}
|
config/discrete/categorical.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import torch
|
| 3 |
+
|
| 4 |
+
CATEGORICAL = {
|
| 5 |
+
"params": lambda: {
|
| 6 |
+
"probs": st.sidebar.text_input("Probabilities (comma-separated)", "0.1,0.2,0.3,0.4"),
|
| 7 |
+
},
|
| 8 |
+
"dist": lambda p: torch.distributions.Categorical(torch.tensor([float(x) for x in p["probs"].split(',')])),
|
| 9 |
+
"support": lambda p: (0, len(p["probs"].split(',')) - 1),
|
| 10 |
+
}
|