Tagged Questions
1
vote
1answer
27 views
Issue with scipy quad integration in python
I'm quite new to python so I'm hoping my wording makes sense. I'm currently attempting to model a set of equations that require the product of an integration to be multiplied by a float. I'm getting a ...
1
vote
3answers
36 views
multiply Python Quad integration by float
Hello I'm quite new to python and I'm trying to work through a set of equations. I'm trying to multiple the result of the quad integration by a float my code is:
from __future__ import division
...
0
votes
0answers
25 views
3D Interpolation in SciPy
I have 3D data on an array of shape [544, 256, 256]. At each grid point, there is a value of a function, say F(x,y,z). I need to interpolate between gridpoints as part of a Runge-Kutta 4th order ...
2
votes
2answers
47 views
Numerical integration over mean of normal in scipy
I'm getting some weird output from the scipy integrate.quad function when integrating a normal pdf. Here is the code I'm trying to use:
inpdf = lambda c: norm.pdf(50, loc=c, scale = 1)
result = ...
0
votes
0answers
9 views
Scipy modules can't be imported in Eclipse
I'm simply trying to import minimize from scipy.optimize as below:
import numpy as np
from scipy.optimize import minimize
However, I always get the following error:
ImportError: cannot import name ...
1
vote
0answers
22 views
pylab not loading in emacs using ipython
I am using Emacs 24.3 in Windows 8. Using PowerShell, ipython loads pylab without issue:
PS C:\Users\vince.forgetta> ipython --pylab
Python 3.4.0 (v3.4.0:04f714765c13, Mar 16 2014, 19:25:23) [MSC ...
2
votes
1answer
61 views
Special kind of row-by-row multiplication of 2 sparse matrices in Python
What I'm looking for: a way to implement in Python a special multiplication operation for matrices that happen to be in scipy sparse (csr) format. This is a special kind of multiplication, not matrix ...
1
vote
1answer
19 views
Paraboloid (3D parabola) surface fitting pythong
I am trying to fit this x data: [0.4,0.165,0.165,0.585,0.585], this y data: [.45, .22, .63, .22, .63], and this z data: [1, 0.99, 0.98,0.97,0.96] to a paraboloid. I am using scipy's curve_fit tool. ...
1
vote
1answer
65 views
How to perform a Kolmogorov-Smirnov goodness of fit test on a custom probability density function in python?
I have an array of experimental values and a probability density function that supposedly describes their distribution:
def bekkers(x, a, m, d):
p = a*np.exp((-1*(x**(1/3) - ...
2
votes
1answer
11 views
Strange “symbolic boolean expression has no truth value” error - is it a bug in SymPy?
Consider the following code:
from sympy import *
from sympy.physics.units import *
x = symbols('x')
eq1 = Eq(10 * (5*kg - x), 5*kg)
eq2 = Eq(10, 5*kg / (5*kg - x))
Unless I am missing something ...
1
vote
1answer
28 views
Fast 1D convolution with finite filter and sum of dirac deltas in python
I need to compute the following convolution:
And K is a very simple filter, that is simply a rectangular box with finite (!) size.
My data is a list of the times t_i of the Dirac deltas.
The ...
0
votes
0answers
19 views
Some questions about scipy.misc.imshow
I just want to use python and scipy write a program achieve gray-level image histogram equalization, however, I find something is wrong when I use misc.imshow function.
I first read an image by ...
0
votes
1answer
29 views
Gradient works for one photo but not others
I am trying to follow the Image Analysis with Scipy guide and mess around with things but a lot of it doesn't work when I change the image. for example,
import skdemo
from skimage import data
# ...
-4
votes
1answer
48 views
how to perform a linear approximation and get linear equation from an array of data in python
I want to know how is it possible to perform a linear approximation and get the linear equation from the array of data in python.
i.e. It would be something like
...
1
vote
1answer
75 views
How to calculate frequency of a give wave and time
I have data for Velocity vs time. The time steps are not uniform, but the Velocity data is a wave. How do I calculate the principal frequency of the velocity using FFT of Python? Most of the examples ...
1
vote
2answers
40 views
Cartesian product to get set of indices to point to unique elements in NumPy array
Whats a good way to get combinations of indices that points to unique elements in array. For example a = [1,1,3,2], the possible set of pointers would be {0,2,3}, {1,2,3}.
I can use argsort in ...
1
vote
1answer
31 views
python scipy ode dopri5 'larger nmax needed'
While using scipy 0.13.0, ode(f).set_integrator('dopri5'), I get the error message -
larger nmax is needed
I looked for nmax in the ode.py but I can't see the variable. I guess that the number call ...
1
vote
0answers
75 views
Minimization leastsq bounds
I m using a least square minimization in order to fit a lot of parameters, but, the results are little surprising, i think it could be due to minimization.
Indeed, when i modify the initialization ...
0
votes
1answer
22 views
KL-Divergence of two GMMs
I have two GMMs that I used to fit two different sets of data in the same space, and I would like to calculate the KL-divergence between them.
Currently I am using the GMMs defined in sklearn ...
1
vote
2answers
35 views
Relatively simple function that mainly performs arithmetic is called many times - naive optimization using Cython by defining types causes slowdowns?
The basic idea of the code is to calculate the push or pull force at a vertex, given the number of "push causing molecules" and "pull causing molecules" at a polygon vertex.
The code thus mainly ...
0
votes
0answers
27 views
Calculate Desirability index using SciPy statistical distributions
I am trying to calculate the desirability index (DI) from a range of descriptors, in this case distributions of specific properties. The DI requires values to be scaled [0 .. 1], where 0 is ...
0
votes
1answer
26 views
Pandas - convert columns to grouped array coordinates
I have a DataFrame of (x, y) coordinates that I would like to transform into array's to perform pairwise distance calculations on.
df = pd.DataFrame({'type': ['a', 'a', 'a', 'b', 'b', 'c', 'c', ...
1
vote
2answers
23 views
How do I get the index of a specific percentile in numpy / scipy?
I have looked this answer which explains how to compute the value of a specific percentile, and this answer which explains how to compute the percentiles that correspond to each element.
Using the ...
0
votes
1answer
51 views
Simulating electron motion - differential equation with adaptive step size in python
I am trying to simulate how the oscillating electric field of an intense laser will push around an electron that is near the Coulomb potential of a +1 ion. The laser field is
E = Eo sin(wt), in the ...
0
votes
1answer
39 views
Interpolation with the most recent value
Say I have a set of (x,y) points in two arrays, x and y of the same length.
I would like to interpolate the values of y for new values of x_new. However, this interpolation should use the last (as ...
1
vote
1answer
42 views
Suitability of cluster analysis [on hold]
I have a large number of objects, for which I calculate 4 percentage differences between each pair.
For example:
O1 and O2 have differences: a12, b12, c12 and d12 e.g. 51, 78, 22, 93.
I wish to ...
1
vote
1answer
45 views
Correct fitting with scipy curve_fit including errors in x?
I'm trying to fit a histogram with some data in it using scipy.optimize.curve_fit. If I want to add an error in y, I can simply do so by applying a weight to the fit. But how to apply the error in x ...
2
votes
1answer
51 views
How to calculate the euclidean distance in Python without fixed-dimension?
I intend to calculate the euclidean distance between two sets of big data. I've googled that the module called SciPy will do the work, whose mechanism is via k-d tree.
But I don't have fixed ...
0
votes
1answer
18 views
scipy polyfit x, y , weights =error bars
I would like to fit a line that uses the inverse of the error
bars as weights.
I binned my data x and y, into 10 bins ( ~26 points each ) and took their mean.
This is not a matrix of values so ...
-1
votes
1answer
31 views
Plotting image Red channel by intensity
Okay, So i'm trying to take the red channel of an image, and plot it (preferably 3d) to an image. The image is 480x640 (or thereabouts), and is taken from a webcam. I'm currently using scipy, numpy, ...
1
vote
3answers
41 views
counting the unique items in a numpy array: why is scipy.stats.itemfreq so slow?
I'm trying to count the unique values in a numpy array.
import numpy as np
from collections import defaultdict
import scipy.stats
import time
x = np.tile([1,2,3,4,5,6,7,8,9,10],20000)
for i in ...
0
votes
1answer
43 views
MPI apparently deadlocking when more than 5 workers are used
I'm writing a python script that uses MPI to send unsorted arrays to workers, that will sort said arrays and return them sorted to master.
Running it with mpirun -n 2 python mpi_sort.py up to mpirun ...
0
votes
0answers
36 views
peak - detection gaussian fitter
I have data for spectral radiance vs. the wavelength. I'm supposed to find the spectral line width for possible spectral lines. Below is the code, I have to identify the spectral lines and do a ...
0
votes
1answer
39 views
ValueError loading data for scipy.odr regression
I recently tried to use scipy.odr package to conduct a regression analysis. Whenever I try to load a list of data where the elements depend on a function, a value error is raised:
ValueError: x ...
0
votes
2answers
19 views
Creating a 2-dimensional Numpy array with the euclidean distance from the center
I'm trying to create a 2-dimensional array in Scipy/Numpy where each value represents the euclidean distance from the center. It's supposed to have the same shape as the first two dimensions of a ...
1
vote
1answer
52 views
How to measure the quality of a best fit line in Python? [duplicate]
I have some data points to plot, and would like to add a best fit line to the graph, and then output the relevant metrics to indicate the quality of the best fit line.
I could plot the data, and ...
2
votes
1answer
20 views
How to remove rows that contain 0 in data array of a scipy.sparse.csr_matrix
I'm currently working on a scipy sparse csr matrix. I would like to delete all rows in the matrix that contain 0 in the data array of the matrix (the data array is the 1s and 2s you can see in the ...
0
votes
1answer
57 views
Create .PNG images in Python from MatLab data
Actually i'm trying to create .png images in Python. The data is get from a Matlab file.
Here my code. When i running i have the error:
Traceback (most recent call last):
File "readFromMatLab.py", ...
1
vote
2answers
42 views
Do calculation for array of values - Python
I am trying to calculate and plot the amplitude amp of the solution of a time dependent t differential equation of motion (see rhs6) as a function of wd for multiple values of the force coefficient f ...
-2
votes
1answer
22 views
python dot operator in 'from import' statement
from . import _nd_image
My question is that there is no such file _nd_image.py in the current directory and code uses this above import statement and below, somewhere in code there is a statement ...
2
votes
2answers
280 views
How to properly stop iteration in minimization in Python?
I am posting this question because, my code is not stopping iteration at the right place. Could anyone make me sure what is wrong?
Everything is working properly (as I always think which is mistake ...
0
votes
1answer
45 views
How do I use Scipy minimize with constraints and dynamic function
I am new to scipy.optimize module and need help trying to use the minimize function on a formula V that works with matrixes and has 2 constraints but I am not sure if I am handling the formation of ...
1
vote
1answer
25 views
Interpolation resampling large irregular matrix or surface data points to regular grid
I am lost in all interpolation methods provided by great SciPy and can't find optimal way for my case.
I have millions of XYZ points in matrix which has different intervals between points (cells) and ...
-1
votes
1answer
12 views
cygwin easy_install scipy error
I am trying to install scipy in cygwin (Win8-64) using easy_install and I have such kind of error:
$ easy_install scipy
Searching for scipy
Reading http://pypi.python.org/simple/scipy/
Best match: ...
0
votes
0answers
25 views
Memory Errors when diagonalizing very large sparse python arrays
For a research project that I am doing, I am diagonalizing huge (10^6 x 10^6) sparse, Hermitian matrices using scipy.sparse's eigsh function. When I run the program, I get a memory error that says ...
0
votes
2answers
20 views
scipy.optimize.newton gives TypeError: 'float' object is not callable
Im new to python and I was writing this simply code for finding the roots of the function:
from scipy import optimize
x = eval(raw_input()) #Initial guess
f = ...
1
vote
1answer
36 views
Scipy odeint with banded jacobian matrix
I'm integrating a system of stiff ODE's using SciPy's integrate.odeint function. As the integration is non-trivial and time consuming I'm also using the corresponding jacobian. By rearranging the ...
1
vote
0answers
52 views
Python: Reshaping arrays and lists
I have a numpy ndarray object with the following shape:
(3, 256, 170, 256).
So, basically this represents an array of 3-dimensional vectors. The dimension of the vector is the first element as it ...
1
vote
0answers
54 views
Numpy python package
I have installed ipython package for windows. I am trying to use "numpy".
My code is as follows:
import numpy as np
np.roots([1,2,1])
When I run it in notebook, or ipython console, it works. But, ...
-1
votes
0answers
35 views
Scipy and python performance optimization
I have written down the following code for performing non linear constrained optimization using scipy,pandas,numpy libs of python .But the performance is dismal.
Can anyone suggest few areas of ...