hello, how do I calculate that an array of python numpy or me of all the calculate decimals and not skip like.
>> A = numpy.array ([[1,2,3], [4,5,6], [7,8,9]]).
>> C = numpy.array ([[7,8,9], [1,2,3], [4,5,6]]).
>> A / C
array ([[0, 0, 0],
[4, 2, 2],
[1, 1, 1]])
but in the first vector would not have to be given to abs...
hello all, as a replacement value for another within an operation with arrays, or how to search within an array and replace a value by another
for example:
array ([[NaN, 1., 1., 1., 1., 1., 1.]
[1., NaN, 1., 1., 1., 1., 1.]
[1., 1., NaN, 1., 1., 1., 1.]
[1., 1., 1., NaN, 1., 1., 1.]
[1., 1., 1., 1., NaN, 1.,...
I have two matrices. Both are filled with zeros and ones. One is a big one (3000 x 2000 elements), and the other is smaller ( 20 x 20 ) elements. I am doing something like:
newMatrix = (size of bigMatrix), filled with zeros
l = (a constant)
for y in xrange(0, len(bigMatrix[0])):
for x in xrange(0, len(bigMatrix)):
for b in...
as I can perform operations on arrays so that does nothing on the diagonal
is calculated such that all but the diagonal
array ([[0., 1.37, 1., 1.37, 1., 1.37, 1.]
[1.37, 0. , 1.37, 1.73, 2.37, 1.73, 1.37]
[1. , 1.37, 0. , 1.37, 2. , 2.37, 2. ]
[1.37, 1.73, 1.37, 0. , 1.37, 1.73, 2.37]
[1. , 2.37, 2...
Let's suppose I have a numpy matrix variable called MATRIX with 3 coordinates: (x, y, z).
Is acessing the matrix's value through the following code
myVar = MATRIX[0,0,0]
equal to
myVar = MATRIX[0,0][0]
or
myVar = MATRIX[0][0,0]
?
What about if I have the following code?
myTuple = (0,0)
myScalar = 0
myVar = MATRIX[myTuple, myS...
Python newbie here.
Are parts of NumPy and/or SciPy programmed in C/C++?
And how does the overhead of calling C from Python compare to the overhead of calling C from Java and/or C#?
I'm just wondering if Python is a better option than Java or C# for scientific apps.
If I look at the shootouts, Python loses by a huge margin. But I gue...
Numpy's meshgrid is very useful for converting two vectors to a coordinate grid. What is the easiest way to extend this to three dimensions? So given three vectors x, y, and z, construct 3x3D arrays (instead of 2x2D arrays) which can be used as coordinates.
...
Hi,
I would like to make a nice function to aggregate data among an array (it's a numpy record array, but it does not change anything)
you have an array of data that you want to aggregate among one axis: for example an array of dtype=[(name, (np.str_,8), (job, (np.str_,8), (income, np.uint32)] and you want to have the mean income per j...
If I have homogeneous linear equations like this
array([[-0.75, 0.25, 0.25, 0.25],
[ 1. , -1. , 0. , 0. ],
[ 1. , 0. , -1. , 0. ],
[ 1. , 0. , 0. , -1. ]])
And I want to get a non-zero solution for it. How can it be done with NumPy?
EDIT
linalg.solve only works on A * x = b where b does not...
I'm trying to pass the values that I want numpy.arange to use.
The code is:
for x in numpy.arange(argument)
where argument is:
argument = (.1,6.3,.1) (tuple)
TypeError: arange: scaler arguements expected instead of a tuple
arguement = [.1,6.3,.1] (list)
TypeError: unsupported operand type(s) for -: 'str' and 'int'
arguement = '...
hello all,
what is the difference between the "Floyd-Warshall algorithm" and "Dijkstra's Algorithm", and which is the best for finding the shortest path in a graph?
I need to calculate the shortest path between all the pairs in a net and save the results to an array as follows:
**A B C D E**
A 0 10 15 5 ...
Hi,
I am looking for an efficient way to compress a numpy array.
I have an array like: dtype=[(name, (np.str_,8), (job, (np.str_,8), (income, np.uint32)] (my favourite example;).
if I'm doing something like this: my_array.compress(my_array['income'] > 10000) I'm getting a new array with only incomes > 10000, and it's quite quick.
But if...
I have two arrays of x-y coordinates, and I would like to find the minimum Euclidean distance between each point in one array with all the points in the other array. The arrays are not necessarily the same size. For example:
xy1=numpy.array(
[[ 243, 3173],
[ 525, 2997]])
xy2=numpy.array(
[[ 682, 2644],
[ 277, 2651],
[ 396, 2640]])
...
I want to create a lambda function that takes two numpy arrays and sets a slice of the first to the second and returns the newly set numpy array.
Considering you can't assign things in lambda functions is there a way to do something similar to this?
The context of this is that I want to set the centre of a zeros array to another array ...
My program uses genetic techniques to build equations.
It randomly assembles strings into an equation with one unknown.
"(((x + 1) * x) / (4 * 6) ** 2)"
One of the strings is: "math.factorial(random.randint(1,9))"
So an equation is typically something like:
"(((x + 1) * x) / (4 * 6) ** 2) + math.factorial(random.randint(1,9))"
Fi...
I find the astype() method of numpy arrays not very efficient. I have an array containing
3 million of Uint8 point. Multiplying it by a 3x3 matrix takes 2 second, but converting the result from uint16 to uint8 takes another second.
More precisely :
print time.clock()
imgarray = np.dot(imgarray, M)/255
print time.clock()
...
Hello -
I want to create a massive TimeSeries object which will hold 1000 different financial markets data series, each storing 1500 daily-data points. I'm quite new to the TimeSeries module and am a little confused as to how I would best go about it. So a few basic questions:
1) Should I use a huge numpy array of 1000x1500 and simply...
If I have two parallel lists and want to sort them by the order of the elements in the first, it's very easy:
>>> a = [2, 3, 1]
>>> b = [4, 6, 2]
>>> a, b = zip(*sorted(zip(a,b)))
>>> print a
(1, 2, 3)
>>> print b
(2, 4, 6)
How can I do the same using numpy arrays without unpacking them into conventional Python lists?
...
Hello I have a 1000 data series with 1500 points in each.
They form a (1000x1500) size Numpy array created using np.zeros((1500, 1000)) and then filled with the data.
Now what if I want the array to grow to say 1600 x 1100? Do I have to add arrays using hstack and vstack or is there a better way?
I would want the data already in the...
Hey all,
I took a scientific programming course this semester that I really enjoyed and experimented with a lot. We used python, and all the related modules. I am taking a physics lab next semester and I just wanted to hear from some of you how python can help me in ways that excel can't or in ways that are better than excel's capabili...