# [SciPy-user] [newbie] standardize a matrix

Noel O'Boyle noel.oboyle2 at mail.dcu.ie
Tue Oct 11 10:11:17 CDT 2005

```I should have said: I'm still using scipy 0.3.2 (the Debian package).

On Tue, 2005-10-11 at 16:40 +0200, Mauro Cherubini wrote:
> On Oct 11, 2005, at 15:10 , Noel O'Boyle wrote:
>
> > On Tue, 2005-10-11 at 15:04 +0200, Mauro Cherubini wrote:
> >
> >> Hi Noel,
> >> thanks for the reply.
> >> Follwoing you advices I implemented this method inside one of my
> >> classes:
> >>
> >> #This method should standardize the matrix
> >>      def standardize_matrix(self, matrix, method='standard'):
> >>          if method == 'max':
> >>              max_x = max(matrix[:,1].flat)
> >>              divide(matrix[:,1], max_x, stdmatrix[:,1])
> >>              max_y = max(matrix[:,2].flat)
> >>              divide(matrix[:,2], max_y, stdmatrix[:,2])
> >>              return stdmatrix;
> >>          if method == 'standard':
> >>              mean_x = mean(matrix[:,1].flat)
> >>              stddev_x = std(matrix[:,1].flat)
> >>              subtract(matrix[:,1], mean_x, stdmatrix[:,1])
> >>              divide(matrix[:,1], stddev_x, stdmatrix[:,1])
> >>              mean_y = mean(matrix[:,2].flat)
> >>              stddev_y = std(matrix[:,2].flat)
> >>              subtract(matrix[:,2], mean_y, stdmatrix[:,2])
> >>              divide(matrix[:,2], stddev_y, stdmatrix[:,2])
> >>              return stdmatrix;
> >>
> >> When I call it from the main it throws this error:
> >>
> >>      mean_x = mean(matrix[:,1].flat)
> >> NameError: global name 'mean' is not defined
> >>
> >> I tried to understand which package are you importing as I initially
> >> thought that was the common scipy base. Apparently I was able to find
> >> a mean() method only inside scipy.stats.stats. However I am not able
> >> to import this. Could you please help me to understand how to call
> >> this method mean() and std()?
> >>
> >> I have a bit of confusion in mind between NumPy and SciPy because I
> >> could not find information in the documentation for SciPy.
> >>
> >
> > from scipy import *
> > mean should then work (it's actually in stats but some of the stats
> > stuff is also imported into the scipy namespace)
> >
>
> Actually this doesn't help. Trying to catch the problem I realised
> that I only installed the 'scipy_core-0.4.1', which is obviously
> missing some stuff (if I have well understood). So I tried to
> complete my installation with the old NumPy (which installed fine)
> and f2py2e (which returned some conflicts warnings). Then I tried to
> compile and install the last complete scipy: SciPy_complete-0.3.2.
>
> The setup doesn't complete and it exits. I found lots of __init__.py
> files missing:
>
> package init file 'scipy_core/weave/tests/__init__.py' not found (or
> not a regular file)
> package init file 'Lib/tests/__init__.py' not found (or not a regular
> file)
> package init file '/Users/mauro/Desktop/python/extra modules/
> a regular file)
>
> And lots of these conflicts:
>
> gcc: Lib/special/cephes/powi.c
> In file included from Lib/special/cephes/mconf_BE.h:190,
>                   from Lib/special/cephes/mconf.h:3,
>                   from Lib/special/cephes/powi.c:46:
> Lib/special/cephes/protos.h:27: warning: conflicting types for built-
> in function 'cexp'
> Lib/special/cephes/protos.h:28: warning: conflicting types for built-
> in function 'csin'
> Lib/special/cephes/protos.h:29: warning: conflicting types for built-
> in function 'ccos'
> Lib/special/cephes/protos.h:30: warning: conflicting types for built-
> in function 'ctan'
>
> Finally the install exit this way:
>
> ranlib:@ build/temp.darwin-8.2.0-Power_Macintosh-2.3/libcephes.a
> building 'dfftpack' library
> compiling Fortran sources
> f95(f77) options: '-fixed -O4'
> f95(f90) options: '-O4'
> f95(fix) options: '-fixed -O4'
> creating build/temp.darwin-8.2.0-Power_Macintosh-2.3/Lib/fftpack
> creating build/temp.darwin-8.2.0-Power_Macintosh-2.3/Lib/fftpack/
> dfftpack
> compile options: '-c'
> f95:f77: Lib/fftpack/dfftpack/dcosqb.f
> sh: line 1: f95: command not found
> sh: line 1: f95: command not found
> error: Command "f95 -fixed -O4 -c -c Lib/fftpack/dfftpack/dcosqb.f -o
> build/temp.darwin-8.2.0-Power_Macintosh-2.3/Lib/fftpack/dfftpack/
> dcosqb.o" failed with exit status 127
> craftmac2:/Users/mauro/Desktop/python/extra modules/
> SciPy_complete-0.3.2 root#
>
> I have to add that I am running this from a Macintosh running OS X
> 10.4.2.
> Can anybody suggest something else to try?
>
> Thanks
>
>
> Mauro
>
>
> --
> web: http://craft.epfl.ch -- blog: http://www.i-cherubini.it/mauro/blog/
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.net
> http://www.scipy.net/mailman/listinfo/scipy-user

```