-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed bernoulli variable to automatically clip to bounds
- Loading branch information
1 parent
c637492
commit 2227e4e
Showing
2 changed files
with
25 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import pymc3 as pm | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
from scipy.stats import norm | ||
|
||
basic_model = pm.Model() | ||
|
||
xdata = np.arange(500) | ||
ydata = 2 * xdata + np.random.randn(500) / 4 + 3 | ||
|
||
with basic_model: | ||
w = pm.Normal('w', mu=0, sigma=5) | ||
b = pm.Normal('b', mu=0, sigma=5) | ||
y = pm.Normal('y', mu=w * xdata + b, sigma=1.0, observed=ydata) | ||
|
||
with basic_model: | ||
data = pm.sample(500) | ||
|
||
pm.traceplot(data) | ||
plt.show() | ||
|
||
print("w: ", data['w'].mean()) | ||
print("b: ", data['b'].mean()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters