0
votes
0answers
14 views

Scipy minimize, fmin, leastsq type problems (setting array element with sequence)

I'm having trouble with the scipy.optimize.fmin and scipy.optimize.minimize functions. I've checked and confirmed that all the arguments passed to the function are of type numpy.array, as well as the ...
1
vote
1answer
24 views

Python - Find K max values in each row of one matrix and compare to binary matrix

I need to determine if the position (index) of the k largest values in matrix a are in the same position as the binary indicator matrix, b. import numpy as np a = ...
0
votes
1answer
25 views

Term document matrix and cosine similarity in Python

I have following situation that I want to address using Python (preferably using numpy and scipy): Collection of documents that I want to convert to a sparse term document matrix. Extract sparse ...
0
votes
3answers
21 views

Looping same program for different data files

For the following program, I am trying to save time copying and pasting tons of code. I would like this program to plot using the data file 19_6.txt and aux.19_6, and then continue by plotting the ...
1
vote
1answer
23 views

Extract non-main diagonal from scipy sparse matrix?

Say that I have a sparse matrix in scipy.sparse format. How can I extract a diagonal other than than the main diagonal? For a numpy array, you can use numpy.diag. Is there a scipy sparse ...
1
vote
0answers
37 views

Numpy: array of indices based on array shape?

say I have a simple array: a = np.zeros([3,3]) >>> [ 0 0 0 , 0 0 0 , 0 0 0 ] Is there a utility function that would give me an array with the same dimensions that contains the ...
1
vote
2answers
53 views

Compare `float` and `float64` in python

I have to compare two numbers. One of them comes from regulat python code and comes other from numpy. Debugger shows they have same value '29.0', but type of first is float and type of second is ...
2
votes
2answers
36 views

load a float+ string table [duplicate]

I have a table which contains both floats and strings. When I'm trying to load it by np.loadtxt(file.txt), I got an error like could not convert string to float: \Omega_b How can I fix it.
0
votes
1answer
36 views

How can I get a column from a 2D python array?

I want to know the co import numpy as np a = np.array([[0,0,0,2,3,0],[3,2,4,0,0,1]]) If I want to get col2 to col4, so result may be: [[0,2,3][4,0,0]] How can I make it? Thanks.
8
votes
1answer
99 views

Numpy: Difference between dot(a,b) and (a*b).sum()

For 1-D numpy arrays, this two expressions should yield the same result (theorically): (a*b).sum()/a.sum() dot(a, b)/a.sum() The latter uses dot() and is faster. But which one is more accurate? ...
6
votes
1answer
99 views

Monte Carlo Simulation with Python: building a histogram on the fly

I have a conceptual question on building a histogram on the fly with Python. I am trying to figure out if there is a good algorithm or maybe an existing package. I wrote a function, which runs a ...
0
votes
1answer
27 views

Unicode portability with PyQT4/numpy on linux

I'm developing a multiplatform application in pyQT4 and numpy and actually it doesn't work on my linux system (Xubuntu 12.04) even so it seems work great on windows 7. So, the problem comes from my ...
1
vote
2answers
76 views

Combining two Gaussians into another Guassian [on hold]

In the code below I have two Gaussian one red and the other in a purple curve. I am wondering if there is a way in python to combining both Gaussian unto a third curve which is suppose to look like ...
0
votes
2answers
44 views

Python: Adding boolean Numpy arrays

I have three lists as such: a = np.array([True, True, False, False]) b = np.array([False, False, False, False]) c = np.array([False, False, False, True]) I want to add the arrays so that the new ...
3
votes
2answers
91 views

Efficient way to create an array that is a sequence of variable length ranges in numpy

Suppose I have an array import numpy as np x=np.array([5,7,2]) I want to create an array that contains a sequence of ranges stacked together with the length of each range given by x: ...

1 2 3 4 5 401
15 30 50 per page