Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix: Ch2 Example: Cheating among students #483

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
80 changes: 23 additions & 57 deletions Chapter2_MorePyMC/Ch2_MorePyMC_PyMC3.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,8 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Applied log-transform to poisson_param and added transformed poisson_param_log_ to model.\n"
]
}
],
"metadata": {},
"outputs": [],
"source": [
"import pymc3 as pm\n",
"\n",
Expand Down Expand Up @@ -1212,21 +1202,12 @@
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Applied interval-transform to freq_cheating and added transformed freq_cheating_interval_ to model.\n"
]
}
],
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
"import pymc3 as pm\n",
"import numpy as np\n",
"\n",
"N = 100\n",
"with pm.Model() as model:\n",
Expand All @@ -1242,14 +1223,13 @@
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {
"collapsed": false
},
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
"with model:\n",
" true_answers = pm.Bernoulli(\"truths\", p, shape=N, testval=np.random.binomial(1, 0.5, N))"
" # true_answers = pm.Bernoulli(\"truths\", p, shape=N, testval=np.random.binomial(1, 0.5, N))\n",
" true_answers = pm.Bernoulli(\"truths\", p, shape=N)"
]
},
{
Expand All @@ -1261,19 +1241,13 @@
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {
"collapsed": false
},
"execution_count": 18,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[0 0 1 0 1 1 0 1 0 1 1 1 0 0 0 1 1 1 0 0 0 0 0 1 0 1 0 1 1 1 0 0 0 1 0 1 1\n",
" 1 1 0 1 0 0 1 1 1 1 0 0 0 0 0 0 1 1 0 0 1 1 0 1 0 0 1 0 1 1 0 0 0 0 0 1 1\n",
" 1 0 1 0 1 1 1 0 1 0 0 0 1 0 0 0 0 1 0 1 0 1 0 0 1 0]\n"
]
"text": "[1 1 0 0 1 1 1 1 0 0 0 1 1 0 1 0 1 0 0 0 0 1 1 1 1 0 0 1 0 1 1 1 1 1 0 1 0\n 0 1 1 0 0 0 0 1 1 1 0 1 1 1 1 1 0 1 0 1 0 0 1 0 1 1 1 0 0 0 1 0 0 1 0 1 1\n 0 1 1 0 1 1 0 0 0 1 1 0 1 1 0 0 1 1 1 0 0 1 1 1 0 0]\n"
}
],
"source": [
Expand All @@ -1291,10 +1265,8 @@
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {
"collapsed": false
},
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
"with model:\n",
Expand All @@ -1310,10 +1282,8 @@
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {
"collapsed": false
},
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
"import theano.tensor as tt\n",
Expand All @@ -1331,18 +1301,14 @@
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {
"collapsed": false
},
"execution_count": 21,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array(0.5600000023841858)"
]
"text/plain": "array(0.23)"
},
"execution_count": 36,
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -2660,9 +2626,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
"version": "3.8.1"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
}