Hello to all,I'm finishing to convert a module for linear regression that I used in Matlab. It takes an experimental matrix, and a response matrix perform a regression and a bit of plot and then give me 3 matrices that I need to plot response surface and leverage surface. For plotting leverage and response I need to create a kind of grid of point with another program. and at this point everything work fine (checked also in comparison with matlab). The problems come when I tri to plot it. For a step of 2 (not really a grid) it works with 30 steps everything crashes :(
so nste=2 work nstep=30 notI attach the file that give no problems it's a module with included the matrix to be plotted with nstep=2 and also the problematic one. a function with the same name of the plot and the matrices that give the problems. Every help would be greatly appreciated because if I fix it I can get rid of the regression program in matlab that i generally use really a lot in my everyday job
Giorgio
test.tar.tar.bz2
Description: Binary data
# plots leverage plot (3d surface+ contour)
from numpy import *
import pylab as p
import matplotlib.axes3d as p3
#nstep 30 doesnt' work
#nstep 2 ok
def pyplotlev(disper,nstep,gr,lab):
h=lab.size
lev2=empty((1,h))
ir=1
for j in arange(1,nstep+2):
#a=gr[[arange(ir-1,ir+nstep)],:]
a2=gr[arange(ir-1,ir+nstep)]
#flev=dot(a2,dot(disper,a2.transpose()))
clev=diag(dot(a2,dot(disper,a2.transpose())))
lev2=vstack((lev2,clev))
#print ir
#print clev
#print h
ir=ir+nstep+1
lev=lev2[1:,]
#print lev
fig=p.figure(1)
H,K = meshgrid(lab,lab)
ax=p3.Axes3D(fig)
ax.plot_wireframe(H,K,lev)
p.close
fig2=p.figure(2)
ic=p.contour(lev)
p.clabel(ic)
p.axis('scaled')
p.close
p.show()
return lev
# plots leverage plot (3d surface+ contour)
#def plotlev(disper,nstep,gr,lab)
#return lev
from numpy import *
import pylab as p
import matplotlib.axes3d as p3
disper=array([[ 3.33333333e-01, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00, 0.00000000e+00, -8.33333333e-02,
-8.33333333e-02, -8.33333333e-02, -8.33333333e-02],
[ 8.06369358e-18, 4.16666667e-02, -7.46669644e-18,
5.44289817e-18, 7.44683153e-19, -3.98129642e-33,
-1.36031186e-33, -2.81282874e-34, 2.25994703e-34,
4.39080865e-34, 2.73462800e-34, -2.51015994e-20,
2.42816787e-18, -5.73736077e-18, -5.73736077e-18],
[ 7.59815453e-34, 2.75067079e-18, 4.16666667e-02,
3.25260652e-18, -6.93889390e-18, 1.88126612e-17,
3.00173761e-18, 5.35741887e-18, 3.92009338e-18,
-1.59648722e-18, -1.47163184e-18, -2.52965300e-18,
1.91454635e-18, -3.63957438e-18, 4.25468104e-18],
[ 1.91623297e-33, 7.20982710e-18, -4.11996826e-18,
4.16666667e-02, 1.56125113e-17, -4.70316529e-18,
-7.50434402e-19, -1.33935472e-18, -9.80023345e-19,
3.99121804e-19, 3.67907960e-19, 1.72379303e-18,
3.94332907e-18, -4.59987963e-18, -1.06724246e-18],
[ 4.89006605e-34, 3.39487908e-18, -8.67361738e-18,
-6.93889390e-18, 4.16666667e-02, -1.81124885e-17,
-1.23264906e-17, 1.26063318e-17, 9.52609141e-18,
-3.43268159e-18, -5.42195377e-18, -4.26328796e-18,
1.35026269e-18, 1.10487576e-18, 1.80814951e-18],
[ 2.53689072e-33, 4.06372644e-33, -2.69948714e-18,
6.74871784e-19, -2.01018321e-17, 6.25000000e-02,
-2.60208521e-17, 2.60208521e-18, -4.33680869e-19,
3.90312782e-18, 1.73472348e-18, -2.23221945e-18,
2.23221945e-18, 5.98507262e-18, -5.98507262e-18],
[ 2.03221450e-34, 1.70837377e-33, -3.99900428e-18,
9.99751071e-19, -9.46725781e-18, -3.90312782e-18,
6.25000000e-02, 3.46944695e-18, -3.46944695e-18,
-1.56125113e-17, -3.46944695e-18, -8.64326920e-18,
8.64326920e-18, 1.55031307e-18, -1.55031307e-18],
[ 8.64890457e-34, -1.47888028e-33, 2.72498991e-18,
-6.81247477e-19, 8.16289482e-18, -1.56125113e-17,
1.38777878e-17, 6.25000000e-02, 1.04083409e-17,
1.04083409e-17, 8.67361738e-18, -5.23347420e-18,
5.23347420e-18, 7.27515326e-19, -7.27515326e-19],
[ 1.78178639e-33, 4.84667488e-34, 6.99282073e-18,
-1.74820518e-18, 1.48015167e-17, -3.90312782e-18,
5.20417043e-18, -6.93889390e-18, 6.25000000e-02,
-1.90819582e-17, -2.68882139e-17, -3.08112113e-18,
3.08112113e-18, -3.02713500e-19, 3.02713500e-19],
[ -1.16429297e-35, 4.79634801e-35, -2.17349863e-18,
5.43374657e-19, -3.83189970e-18, 1.73472348e-18,
-4.33680869e-18, 5.20417043e-18, -1.21430643e-17,
6.25000000e-02, 6.07153217e-18, -6.22253184e-18,
6.22253184e-18, 2.96296860e-19, -2.96296860e-19],
[ 1.42465821e-34, 1.91195768e-34, 3.41641266e-19,
-8.54103164e-20, -1.54479608e-18, -3.46944695e-18,
6.93889390e-18, 5.20417043e-18, -6.93889390e-18,
-2.34187669e-17, 6.25000000e-02, -1.05821629e-18,
1.05821629e-18, -1.63231315e-20, 1.63231315e-20],
[ -8.33333333e-02, -3.16474317e-18, 3.26740831e-18,
2.29332839e-18, 2.82259141e-18, 6.75185432e-18,
-1.40407181e-17, 2.31571228e-17, 2.87211757e-17,
-1.25189972e-17, 2.32568943e-18, 4.68750000e-02,
1.56250000e-02, 1.56250000e-02, 1.56250000e-02],
[ -8.33333333e-02, -8.82944936e-19, 3.93587120e-18,
1.86622517e-18, -3.65488434e-18, -6.75185432e-18,
1.40407181e-17, -2.31571228e-17, -2.87211757e-17,
1.25189972e-17, -2.32568943e-18, 1.56250000e-02,
4.68750000e-02, 1.56250000e-02, 1.56250000e-02],
[ -8.33333333e-02, 2.02384406e-18, 1.03427776e-19,
-2.39272630e-18, 1.01400502e-17, -2.49810195e-17,
-1.25610840e-17, 6.34456852e-19, 7.28928426e-19,
-6.89594086e-20, -4.96495518e-19, 1.56250000e-02,
1.56250000e-02, 4.68750000e-02, 1.56250000e-02],
[ -8.33333333e-02, 2.02384406e-18, -7.30670729e-18,
-1.76682726e-18, -9.30775722e-18, 2.49810195e-17,
1.25610840e-17, -6.34456852e-19, -7.28928426e-19,
6.89594086e-20, 4.96495518e-19, 1.56250000e-02,
1.56250000e-02, 1.56250000e-02, 4.68750000e-02]])
gr=array([[ 1., -1., -1., 0., 0., 1., 0., 0., 0., 0., 0., 1., 1.,
0., 0.],
[ 1., -1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0.,
0., 0.],
[ 1., -1., 1., 0., 0., -1., 0., 0., 0., 0., 0., 1., 1.,
0., 0.],
[ 1., 0., -1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.,
0., 0.],
[ 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0.],
[ 1., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.,
0., 0.],
[ 1., 1., -1., 0., 0., -1., 0., 0., 0., 0., 0., 1., 1.,
0., 0.],
[ 1., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0.,
0., 0.],
[ 1., 1., 1., 0., 0., 1., 0., 0., 0., 0., 0., 1., 1.,
0., 0.]])
lab=array([-1., 0., 1.])
nstep=2
h=lab.size
lev2=empty((1,h))
ir=1
for j in arange(1,nstep+2):
a2=gr[arange(ir-1,ir+nstep)]
clev=diag(dot(a2,dot(disper,a2.transpose())))
lev2=vstack((lev2,clev))
#print ir
#print clev
#print h
ir=ir+nstep+1
lev=lev2[1:,]
#print lev
fig=p.figure(1)
H,K = meshgrid(lab,lab)
ax=p3.Axes3D(fig)
ax.plot_wireframe(H,K,lev)
p.close
fig2=p.figure(2)
ic=p.contour(lev)
p.clabel(ic)
p.axis('scaled')
p.close
p.show()
------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
