In [0]:
import numpy as np
import pandas as pd
from scipy.stats import binom
import matplotlib.pyplot as plt
%matplotlib inline

In [2]:
rawdata = pd.read_csv('https://raw.githubusercontent.com/tomfaulkenberry/physNumComparisonTask/master/results/processed.csv')
data = rawdata.query('response_time < 2000')
data.head()


Out[2]:
congruity correct distance leftStimulus response response_time rightStimulus subject_nr
0 incongruent 1 3 5 l 763 2 101
1 congruent 1 1 2 l 650 3 101
2 incongruent 1 4 7 l 654 3 101
3 congruent 1 4 3 l 488 7 101
4 congruent 1 3 4 l 438 7 101

In [10]:
fig, ax = plt.subplots()

ax.hist(data.response_time[data.congruity=='congruent'], bins=30, color='blue', edgecolor='black', label='Congruent trials')
ax.hist(data.response_time[data.congruity=='incongruent'], bins=30, color='white', edgecolor='black', alpha=0.8, label='Incongruent trials')

ax.set_xlabel('Response time (ms)', fontsize=14)
ax.legend()

plt.show()



In [0]:


In [0]:
binom.pmf(3, 10, 0.2)


Out[0]:
0.20132659200000022

In [0]:
fig, ax = plt.subplots()

Y = np.arange(0,10)
P = binom.pmf(Y, 10, 0.2)

ax.bar(Y,P)

ax.set_xlabel('$y$', fontsize=14)
ax.set_ylabel('$p(y\mid \\theta=0.2)$', fontsize=14)

plt.show()



In [0]:
fig, ax = plt.subplots()

Y = np.arange(0,10)
P = binom.pmf(Y, 10, 0.7)

ax.bar(Y,P)

ax.set_xlabel('$y$', fontsize=14)
ax.set_ylabel('$p(y\mid \\theta=0.7)$', fontsize=14)

plt.show()



In [0]:
def L(x):
  return(binom.pmf(7, 10, x))

fig, ax = plt.subplots(figsize=(8,5))
Theta = np.linspace(0,1,100)

ax.plot(Theta, L(Theta))

ax.set_xlabel('$\\theta$', fontsize=14)
ax.set_ylabel('$L(\\theta \mid y=7)$', fontsize=14)

plt.show()