numpy

difficulty in installing SciPy and Numpy in Ubuntu(9.04)?

HI folks. I have difficulty in installing these items in Ubuntu.......plz help me as soon as possible.iam experiencing errors such as no module name found......sometimes certain libraries are not found.......plz folks can all of u state the basic libraries required for installing these items and where to find them ...

Numpy matrix operations

I want to compute the following values for all i and j: M_ki = Sum[A_ij - A_ik - A_kj + A_kk, 1 <= j <= n] How can I do it using Numpy (Python) without an explicit loop? Thanks! ...

how do matlab do the sort??

How is the sort() working in matlab? Code in pure matlab: q is an array: q = -0.2461 2.9531 -15.8867 49.8750 -99.1172 125.8438 -99.1172 49.8750 -15.8867 2.9531 -0.2461 After q = sort(roots(q)), I got: q = 0.3525 0.3371 - 0.1564i 0.3371 + 0.1564i 0.2694 - 0.3547i 0.2694 + 0.3547i ...

Fill in missing values with nearest neighbour in Python numpy masked arrays?

I am working with a 2D Numpy masked_array in Python. I need to change the data values in the masked area such that they equal the nearest unmasked value. NB. If there are more than one nearest unmasked values then it can take any of those nearest values (which ever one turns out to be easiest to code…) e.g. import numpy import numpy.m...

Numpy: How to split/partition a dataset (array) into training and test datasets for, e.g., cross validation?

What is a good way to split a numpy array randomly into training and testing / validation dataset? Something similar to the cvpartition or crossvalind functions in Matlab. ...

Slice a 2D Python Array

I have a 2d array in the numpy module that looks like: data = array([[1,2,3], [4,5,6], [7,8,9]]) I want to get a slice of this array that only includes certain columns of element. For example I may want columns 0 and 2: data = [[1,3], [4,6], [7,9]] What is the most Pythonic way to do thi...

How to write a multidimensional array to a text file?

In another question, other users offered some help if I could supply the array I was having trouble with. However, I even fail at a basic I/O task, such as writing an array to a file. Can anyone explain what kind of loop I would need to write a 4x11x14 numpy array to file? This array consist of four 11 x 14 arrays, so I should format i...

[numpy] creating a masked array from text fields

The numpy documentation shows an example of masking existing values with ma.masked a posteriori (after array creation), or creating a masked array from an list of what seem to be valid data types (integer if dtype=int). I am trying to read in data from a file (and requires some text manipulation) but at some point I will have a list of l...

how to extract frequency associated with fft values in python

hi i used fft function in numpy which resulted in a complex array.how to get the exact frequency values? ...

Scipy sparse matrix question

Hi, I have the following code in Python using Numpy: p = np.diag(1.0 / np.array(x) How can I transform it to get the sparse matrix p2 with the same values as p without creating p first? Thanks! ...

Recognizing notes within recorded sound - Part 2 - Python

Hi folks, this is a continuation of this question here. This is the code I used in order to get the samples: spf = wave.open(speech,'r') sound_info = spf.readframes(-1) sound_info = fromstring(sound_info, 'Int16') The length of sound_info is 194560, which is 4.4 times the sample rate of 44100. The length of the sound file is 2.2 s...

Memory error (MemoryError) when creating a boolean NumPy array (Python).

I'm using NumPy with Python 2.6.2. I'm trying to create a small (length 3), simple boolean array. The following gives me a MemoryError, which I think it ought not to. import numpy as np cond = np.fromiter((x in [2] for x in [0, 1, 2]), dtype = np.bool) The error it gives me is: MemoryError: cannot allocate array memory However, the ...

What is the reason for an unhandled win32 exception in an installer program?

I got the following message: An unhandled win32 exception occurred in numpy-1.5.0-sse3.exe [3324]. The exception occurred in the Numpy installer for Python 2.7---I have the latter on the machine. When I clicked "Yes" for using the selected debugger, I got the following message: The Application Data folder for Visual Studio could not ...

Numpy Modular arithmetic

Hi, How can I define in numpy a matrix that uses operations modulo 2? For example: 0 0 1 0 1 0 1 1 + 0 1 = 1 0 Thanks! ...

Is it possible to reproduce randn() of MATLAB with NumPy?

Hi, I wonder if it is possible to exactly reproduce the whole sequence of randn() of MATLAB with NumPy. I coded my own routine with Python/Numpy, and it is giving me a little bit different results from the MATLAB code somebody else did, and I am having hard time finding out where it is coming from because of different random draws. I h...

beep sound in python audiolab

How do i generate a gentle "beep" sound in python audiolab, without the use of external .wav files? I found the following example to generate random noise: play(0.05 * np.random.randn(2, 48000)) Unfortunately i do not have enough knowledge of audio representations to create a beep (of a certain frequency) and i have no idea where to f...

numpy array <=> python DB-API adapter?

Dear All, Anyone knows is there any other adapter between numpy array and sqlite database besides the atpy? Thanks! Rgs, KC ...

specify dtype of each object in a python numpy array

This is a similar question using dtypes in a list The following snippet creates a "typical test array", the purpose of this array is to test an assortment of things in my program. Is there a way or is it even possible to change the type of elements in an array? import numpy as np import random from random import uniform, randrange, c...

Translate matlab to python/numpy

hi, i am looking for a automatic translator from Matlab to python. I downloaded and installed LiberMate but it not documented anywhere and i wasn't able to make it work. Has anybody dealt with this kind of challenge before? Any advice welcome. ...

How to insert arrays into a database?

In my previous question a lot of users wanted me to give some more data to toy with. So I got working on exporting all my data and processing it with Python, but then I realized: where do I leave all this data? Well I decided the best thing would be to stick them in a database, so at least I don't have to parse the raw files every time...