107 lines
3.2 KiB
Python
107 lines
3.2 KiB
Python
from __future__ import division
|
|
import seaborn as sns
|
|
import sys
|
|
sys.path.append('/home/fabee/code/')
|
|
from matplotlib.pyplot import *
|
|
from fabee.Plotting import *
|
|
from scipy import stats
|
|
from numpy import *
|
|
|
|
sns.set_context("talk", font_scale=1.5, rc={"lines.linewidth": 2.5})
|
|
|
|
# ---------------------------------------------------------------------------
|
|
fig, ax = subplots()
|
|
fig.subplots_adjust(bottom=.3, left=.3)
|
|
n = 50
|
|
x = loadtxt('scripts/thymusglandweights.dat')[:n]
|
|
ax.bar([0,1],[mean(x),mean(x)],yerr = [std(x,ddof=1), std(x,ddof=1)/sqrt(n)],
|
|
facecolor='dodgerblue', alpha=.8,width=.7, align='center',
|
|
error_kw={'color':'k','lw':2}, capsize=10, ecolor='k')
|
|
ax.set_title('standard deviation or standard error?',fontsize=14, fontweight='bold')
|
|
|
|
ax.set_xlim([-.5,1.5])
|
|
box_off(ax)
|
|
#disjoint_axes(ax)
|
|
ax.set_xticks([0,1])
|
|
ax.set_xticklabels([r'$\hat\sigma$', r'$\frac{\hat\sigma}{\sqrt{n}}$'], fontsize=30)
|
|
|
|
ax.set_ylabel(r'$\frac{1}{n}\sum_{i=1}^n x_i$',fontsize=30, fontweight='bold')
|
|
|
|
fig.savefig('figs/StandardErrorOrStandardDeviation.pdf')
|
|
|
|
# ---------------------------------------------------------------------------
|
|
fig, ax = subplots()
|
|
|
|
t = linspace(-5,5,1000)
|
|
t2 = linspace(stats.laplace.ppf(0.025),stats.laplace.ppf(1-0.025),1000)
|
|
|
|
ax.fill_between(t,stats.laplace.pdf(t),color='dodgerblue')
|
|
ax.set_xticks([])
|
|
ax.text(5,-0.05, r'$\hat m$',fontsize=30)
|
|
ax.text(0,0.7, r'$m$',fontsize=30)
|
|
ax.set_yticks([])
|
|
#disjoint_axes(ax)
|
|
box_off(ax)
|
|
|
|
ax.set_title('putative sampling distribution of the median',fontsize=14, fontweight='bold')
|
|
ax.axis([-5,5,0,.8])
|
|
ax.plot([0,0],[0,.7],'--k',lw=2)
|
|
|
|
fig.savefig('figs/samplingDistributionMedian00.pdf')
|
|
|
|
ax.fill_between(t2,stats.laplace.pdf(t2),color='crimson')
|
|
|
|
fig.savefig('figs/samplingDistributionMedian01.pdf')
|
|
|
|
# ---------------------------------------------------------------------------
|
|
fig, ax = subplots()
|
|
k = 7
|
|
N = 21
|
|
F = stats.f
|
|
t = linspace(1e-6,8,1000)
|
|
t2= linspace(F.ppf(0.95,k-1,N-k),8,1000)
|
|
|
|
ax.fill_between(t,F.pdf(t,k-1,N-k),color='dodgerblue')
|
|
ax.fill_between(t2,F.pdf(t2,k-1,N-k),color='crimson')
|
|
ax.set_xlabel('group MS/ error MS')
|
|
ax.set_ylabel(r'p(group MS/ error MS| $H_0$)')
|
|
ax.set_title('F-distribution',fontsize=14, fontweight='bold')
|
|
ax.set_ylim((0,0.8))
|
|
box_off(ax)
|
|
fig.savefig('figs/Fdistribution00.pdf')
|
|
|
|
# ---------------------------------------------------------------------------
|
|
fig, ax = subplots()
|
|
n = 5
|
|
p = stats.t.pdf
|
|
t = linspace(-5,8,1000)
|
|
t0 = 1.5
|
|
t00 = 1.
|
|
|
|
mu0 = 3
|
|
t1 = linspace(-5,t00,1000)
|
|
t2 = linspace(t0,8,1000)
|
|
t3 = linspace(-5,-t0,1000)
|
|
ax.fill_between(t,p(t,n-1),color='dodgerblue',alpha=1)
|
|
ax.fill_between(t2,p(t2,n-1),color='indigo',alpha=1)
|
|
ax.fill_between(t3,p(t3,n-1),color='indigo',alpha=1)
|
|
ax.set_xlabel('t')
|
|
ax.set_ylabel(r'sampling distribution')
|
|
ax.set_ylim((0,0.8))
|
|
box_off(ax)
|
|
fig.savefig('figs/experimentalDesign00.pdf')
|
|
|
|
|
|
ax.fill_between(t,p(t,n-1,loc=mu0),color='lime',alpha=.5)
|
|
ax.fill_between(t1,p(t1,n-1,loc=mu0),color='magenta',alpha=1)
|
|
ax.arrow(0,.4,mu0,0,head_width=0.05)
|
|
ax.arrow(mu0,.4,-mu0,0,head_width=0.05)
|
|
ax.text(mu0/2,.45,r'$\delta$',fontsize=20)
|
|
ax.set_xlabel('t')
|
|
ax.set_ylabel(r'sampling distribution')
|
|
ax.set_ylim((0,0.8))
|
|
box_off(ax)
|
|
fig.savefig('figs/experimentalDesign01.pdf')
|
|
|
|
|