예제 #1
0
plot(time, logrecov, 'ko')                    # Plots log recovery vs. time
xlim([-5,65])                                 # Sets x-limits on plot
xlabel('Time (in minutes)')
ylabel('Log Biological Recovery Percentage')
title('Scatterplot of Log Recovery vs. Time')
grid()
#savefig('../doc/images/prb1b.png', dpi=300)
show()


# ===================================================================== #
# Problem 1: Regression of log biological recovery percentages vs. time #
# ===================================================================== #
x   = time
y   = logrecov 
out = linRegstats(x, y, 0.95) # get regression statistics for linear model

ci_b = out['CIB']
ci_y = out['CIY']
bhat = out['bhat']
yhat = out['yhat']

# plot the solutions :
plot(x, y, 'ko')
plot(x, yhat, 'r-', lw=2.0, 
     label=r'least squares')
plot(x, ci_b[0,0] + ci_b[0,1]*x, 'k--', lw=2.0, 
     label=r'99% CI for $\hat{\beta}$')
plot(x, ci_b[1,0] + ci_b[1,1]*x, 'k--', lw=2.0)
plot(x, ci_y[0], 'k:', lw=2.0, label=r'99% CI for $\hat{y}$')
plot(x, ci_y[1], 'k:', lw=2.0)
예제 #2
0
lat = data["evol"]["latitude"][0][0].T[0]
wing = data["evol"]["wingsize"][0][0].T[0]
cont = data["evol"]["cont"][0][0].T[0]

nam = where(cont == "NAM")
eur = where(cont == "EUR")
n = len(lat)

x1 = lat
x2 = (cont == "EUR").astype(float)
x3 = x1 * x2

X = array([x1, x2, x3])
y = wing

out = linRegstats(X, y, 0.95)

bhat = out["bhat"]
yhat = out["yhat"]

ciy = out["CIY"]

plot(lat[nam], wing[nam], "ko", label=r"NAM")
plot(lat[eur], wing[eur], "ro", label=r"EUR")
plot(lat[nam], yhat[nam], "k-", lw=2.0, label=r"NAM $\vec{x}_{LS}$")
plot(lat[eur], yhat[eur], "r-", lw=2.0, label=r"EUR $\vec{x}_{LS}$")
plot(lat[nam], ciy[0][nam], "k:", lw=3.0, label=r"NAM C.I.")
plot(lat[nam], ciy[1][nam], "k:", lw=3.0)
plot(lat[eur], ciy[0][eur], "r:", lw=3.0, label=r"EUR C.I.")
plot(lat[eur], ciy[1][eur], "r:", lw=3.0)
xlabel("Latitude")
예제 #3
0
v_v = v_v[i]
z_v = z_v[i]
x_v = x_v[i]
y_v = y_v[i]
w_v = w_v[i]

x1 = u_v
x2 = v_v
x3 = z_v
x4 = np.sqrt(x_v**2 + y_v**2 + 1e-10)
x5 = x1 * x2 * x3

X = array([x1, x2, x3, x4, x5])
yt = w_v

out = linRegstats(X, yt, 0.95)

bhat = out['bhat']
yhat = out['yhat']
ciy = out['CIY']

print out['F_pval'], out['pval']

fig = figure()
ax = fig.add_subplot(111)

ax.plot(u_v, yt, 'ko', lw=2.0)
ax.plot(u_v, yhat, 'r-', lw=2.0)
#ax.plot(u_v, ciy[0], 'k:', lw=2.0)
#ax.plot(u_v, ciy[1], 'k:', lw=2.0)
ax.set_xlabel(r'$u$')