[Numpy-discussion] Array as Variable using "from cdms2 import MV2 as MV"
dileep kunjaai
dileepkunjaai at gmail.com
Mon Apr 25 02:50:53 EDT 2011
Dear sir,
I am have 2 mxn numpy array say "obs" & "fcst". I have to
calculate * sum of squre of (obs[i, j]-fcst[i, j])* using from cdms2
import MV2 as MV in CDAT without using "for" loop.
For example:
obs=
[0.6 1.1 0.02 0.2 0.2
0.8 0. 0. 0.4 0.8
0.5 5.5 1.5 0.5 1.5
3.5 0.5 1.5 5.0 2.6
5.1 4.1 3.2 2.3 1.5
4.4 0.9 1.5 2. 2.3
1.1 1.1 1.5 12.6 1.3
2.2 12 1.7 1.6 15
1.9 1.5 0.9 2.5 5.5 ]
fcst=
[0.7 0.1 0.2 0.2 0.2
0.3 0.8 0. 0. 0.
0.5 0.5 0.5 0.5 0.5
0.7 1. 1.5 2. 2.6
5.1 4.1 3.2 2.3 1.5
0.7 1. 1.5 2. 2.3
1.1 1.1 1.1 12.7 1.3
2.2 2. 1.7 1.6 1.5
1.9 1.5 0.9 0.5 7.5]
here "obs" and "fcst" are numpy array
I give
obs=MV.array(obs)
fcst=MV.array(fcst)
Then it become
sbst=obs-fcst
>> subst=
[[ -0.1 1. -0.18 0. 0. ]
[ 0.5 -0.8 0. 0.4 0.8 ]
[ 0. 5. 1. 0. 1. ]
[ 2.8 -0.5 0. 3. 0. ]
[ 0. 0. 0. 0. 0. ]
[ 3.7 -0.1 0. 0. 0. ]
[ 0. 0. 0.4 -0.1 0. ]
[ 0. 10. 0. 0. 13.5 ]
[ 0. 0. 0. 2. -2. ]]
But i dont know how to find sum of squre of each term....(Actually my aim is
to finding MEAN SQUARED ERROR)
Thanking you...................
--
DILEEPKUMAR. R
J R F, IIT DELHI
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110425/2be25f4c/attachment.html>
More information about the NumPy-Discussion
mailing list