Join us in building a kind, collaborative learning community via our updated Code of Conduct.

Questions tagged [scipy]

SciPy is an open source library of algorithms and mathematical tools for the Python programming language.

1
vote
0answers
15 views

Python Pandas and Spearmanr rowwise run faster

I'm trying to take two dataframes and run row wise spearmanr correlation. I've set the code up so it runs but it is taking a very long time, and I was hoping that there is a better/faster way to run ...
0
votes
0answers
4 views

Python PyInstaller: ModuleNotFoundError no module found 'scipy._lib.messagestream'

I'm trying to create an executable file from a Python script using PyInstaller. When I run pyinstaller --onefile myscript.py, I get the error: Traceback (most recent call last): File "omr.py", line ...
0
votes
0answers
15 views

How to apply FFT on raw signal using Python

I'm new in processing signals and need your help. I have acquired a 10 seconds raw PPG (Photoplethysmogram) signal from my TI AFE4490. My hardware is calibrated and I'm using 250 samples per second ...
0
votes
0answers
23 views

Module 'scipy.special' has no 'expit' member

I am trying to use the sigmoid function from scipy. The scipy module is imported like: import scipy.special. The variable is assigned like: self.activation_function = lambda x: scipy.special.expit(x). ...
0
votes
0answers
15 views

Why is scipy's entropy function returning a value greater than 1?

Scipy's entropy function calculates the Kullback–Leibler divergence using base e as the default. According to wikipedia, the KL divergence cannot be greater than one when using base e. I found a case ...
0
votes
0answers
28 views

scipy.optimize.minimize is too slow. How can I speed up

Firstly I am sorry for my bad English. I am converting an IDL code (belonging to Oleg Kochukhov) to Python. The code creates star surface map over spectral line profiles using Tikhonov or Maximum ...
0
votes
1answer
50 views

Python libraries name stands for [on hold]

I know the purposes of NumPy, SciPy, Pandas, Scikit-Learn, matplotlib and Seaborn. However, I'm interested to know actually what they stand for? NumPy : Numerical Python SciPy : Scientific Python ...
1
vote
0answers
16 views

Passing constants and variables into Scipy.minimize.optimize constraints and boundaries

I found how one can pass *args into the main function of scipy.minimize.optimize, see this question. But how do I pass constants and variables into constraints and boundaries? P is a variable vector,...
-2
votes
2answers
31 views

Matching two data sets of different sizes

I have two datasets with different sample rates and a different amount of samples, but both start at the same time and end at nearly the same time. The first column of each dataset is time, how can I ...
0
votes
1answer
19 views

Solving system of four nonlinear equations

I am trying to solve a system of four non-linear equations using fsolve from scipy.optimize module. The Jacobian matrix (fjac) is filled with nan. I don't understand what I am doing wrong. I've looked ...
1
vote
0answers
25 views

Weighted Voronoi Diagram

I would like to know how to create weighted Voronoi diagram. (For example, additively weighted Voronoi diagram and multiplicatively weighted Voronoi diagram.) In my recognition, a class of scipy....
1
vote
0answers
31 views

Store vertices of Polygons from Binary Image in an array

I want to extract ordered polygons representing the coastline from binary-data (1 for land, 0 for water). The goal is to describe the coastline of a polygon by getting an array beginning in Point A ...
6
votes
2answers
47 views

scipy.curve_fit vs. numpy.polyfit different covariance matrices

I am using Python 3.6 for data fitting. Recently, I came across the following problem and I’m lacking experience wherefore I’m not sure how to deal with this. If I use numpy.polyfit(x, y, 1, cov=True)...
1
vote
0answers
23 views

Scipy ODE time steps going backward

I've looked around on Stackoverflow, but could not find anything that would answer my question. Problem Setup: I am trying to solve a system of stiff ODEs using scipy.integrate.ode. Part of my code ...
0
votes
1answer
28 views

Python - Increment time by random variable

I'm trying to increment a time by a random number of minutes. The time is 09:50 and I'd like to increment it by between -5 minutes or +5 minutes. This will be stored as a function. Currently I'm ...
0
votes
0answers
25 views

Python Pandas Linear Regression on an Expanding Dataframe

I have pandas dataframe and interested in getting the linear regression results using an expanding window on the column "Price". For example obtaining the slope and intercept of the first two points, ...
0
votes
0answers
13 views

Best way to store attribute data in scipy sparse matrix?

I want to create a scipy csr_matrix to represent a sparse graph. For each edge, along with the weight, I want to define several "attributes." One of the attributes will be accessed directly after the ...
0
votes
0answers
11 views

Update the Kernel Density as the new data comes in

How to incrementally update the parameters characterizing the kernel density estimator(KDE) fit to the old data with new data coming in periodically? I have got a KDE fitted to the data. Say it is ...
-2
votes
0answers
27 views

python scipy.optimize.minimize to find multiple parameters of the model

I am trying to find the multiple parameters to fit the model to the experimental data. The parameters ai and bi are N=8 sets of independent parameters. They were obtained by "scipy.optimize....
5
votes
2answers
52 views

Integrating equation using scipy

from scipy.integrate import quad def integrand(a, b): return a * x ** 2 + b a = 2 b = 1 I = quad(integrand, 0, 1, args=(a,b)) I This is my program. When I tried to run it, it was showing error ...
1
vote
0answers
19 views

Most efficient way to add two CSR sparse matrices with the same sparsity pattern in python

I am using sparse matrices in python, namely scipy.sparse.csr_matrix I am in principle free to choose the exact sparse implementation, as long as the matrices support matrix-vector multiplication ...
1
vote
1answer
24 views

Creating determinant function for optimization in SciPy

I'm trying to learn how to use scipy.optimize. As a warm up example, I am trying to minimize the determinant of 2 by 2 matrices with entries bounded in absolute value by .5. I define a function det(x) ...
1
vote
2answers
31 views

Python program using numpy and Scipy to calculate triple integration?

from scipy import integrate import numpy as np def f(x,z): return (3*x**2 + 3*z**2)**0.5 def limits_y(x,z): return [(2*x**2+2*z**2),8] def limits_z(): return [0,2*np.pi] def ...
1
vote
1answer
24 views

Does Scipy linalg.eig produce all possible eigenvectors?

I have this matrix a - array([[2, 1], [1, 2]]) This matrix has [1, 3] eigenvalues and following eigenvectors: array([1, -1]) array([1, 1]) But when I use Scipy's linalg.eig function, it ...
0
votes
1answer
21 views

How to print whole sparse matrix?

I want to print the whole matrix. When I print X it tells me location where values are stored expcept zeros. Can I print whole matrix including zeros? X = sparse.csr_matrix(1./2.*np.array([[0.,1.],[1....
0
votes
1answer
26 views

Is `sigma` expressed in the units of pixel for `gaussian_filter`?

I am looking at scipy.ndimage.gaussian_filter, and could not get what sigma means here. Is sigma= n means n is the number of pixels, thus a region within n number of pixel on all sides of a point ...
0
votes
2answers
36 views

Appropriate numpy/scipy function to interpolate function defined on simplex (non regular grid)

I've got a function defined on a 3-dimensional simplex. That is, the set of points x, y, z, each between 0 and 1, such that x + y + z = 1.0 For example, if I consider 4 points for each x, y and z, ...
2
votes
2answers
30 views

How to random sample a 2-parameter weibull distribution in python

I was wondering how to generate a random weibull distribution with 2-parameter (lambda, k) in python. I know that numpy has a numpy.random.weibull, but it only accepts the a parameter as the shape of ...
-2
votes
1answer
31 views

How can I smoothly scale a specific region in a signal with Python / Scipy?

I need to scale a curve as shown on the picture underneath. The curve is a two-dimensional array consisting of many X and Y values. It is important that the curve stays continuous and there is no "...
0
votes
1answer
43 views

Comparing two pandas dataframes on column and the row

I have two pandas dataframes that look about the same but with different information stored in them. My question will be about how to compare the two dataframes to ensure column and row match before ...
0
votes
1answer
22 views

What is difference between Noise Filters (Savitzki Golay) and Interpolation(interp1d) Python

I am wondering what is difference between filtering and interpolating data. I am now comparing savgol_filter(itp(xx), window_size, poly_order) and itp = interp1d(x,y, kind='nearest') I ...
2
votes
1answer
25 views

Eigenvectors of a large sparse matrix in tensorflow

I was wondering if there is a way to calculate the first few eigenvectors of a very large sparse matrix in tensorflow, hoping that it might be faster than scipy's implementation of ARPACK, which doesn'...
1
vote
1answer
29 views

Python: Assign identical objects to same label over time

I have the following problem. I have stacks of 2d images over time. They are already segmented. But unfortunatly in every time step the same object has a different label number. Is there maybe an easy ...
0
votes
0answers
24 views

RuntimeError: Optimal parameters not found: Number of calls to function has reached maxfev = 1000

I have the following code which throws me error: RuntimeError: Optimal parameters not found: Number of calls to function has reached maxfev = 1000 I think it is due to the def func in the loop. ...
-2
votes
0answers
18 views

Hartley's Fmax test in python

I would like to do the Hartley Fmax test in python (similar to what we already have in R https://www.rdocumentation.org/packages/SuppDists/versions/1.1-9.4/topics/maxFratio) Unfortunately I cannot ...
-2
votes
0answers
24 views

Search point is under curve [on hold]

is there any method in library (scipy, numpy) which can find point (x, y) is under specify curve (calculated from set of 3 points (x, y)?
0
votes
2answers
41 views

Fast euclidean distances between two sets of points with missing values in Python

I have two numpy matrices X and Y representing each a set of points in some d-dimensional space. I would like to compute all the euclidean distances from each point in X to each point in Y. scipy ...
1
vote
1answer
19 views

stats.rv_continuous slow when when using custom pdf

Ultimately I am trying to visualise the copula between two PDFs which are estimated from data (both via a KDE). Suppose, for one of the KDEs, I have discrete x,y data sorted in a tuple called data. I ...
0
votes
0answers
21 views

raspberry pi 3 suffers lack of memory when pip instal keras==2.2.2?

I am trying to install keras==2.2.2 on my raspberry pi 3. It has 1 GB of memory. And pip install does compile its dependencies scipy, numpy and h5py etc. All is good. But sometimes, it is using 3 ...
0
votes
0answers
22 views

Reconstruction of original signal from instantaneous amplitude and frequency

I have a signal that looks like an AM-wave and am passing it to the Hilbert Transform to get information on the instantaneous envelope, frequency, and phase. I was just wondering that if once I get ...
4
votes
1answer
43 views

Is scipy.stats doing wrong calculation for iqr?

i am coding on a dataset [23,25,28,28,32,33,35] according to wiki and scipy doc IQR = Q3 − Q1 = 33 - 25 = 8 when I run IQR on a dataset, the result (6) is not as expected (8). I tried another ...
0
votes
0answers
16 views

Python 2.7 fitting returns wrong values from multiple methods

I am using Python 2.7. to general data analysis of various sorts however I am facing a problem with fitting my data. If I try to fit my data using Binned LH, UnBinned LH, Chi2, Kmeans etc - the ...
0
votes
1answer
23 views

Plot Scipy ODE solution

I've been trying to solve a nonliner ordinary differential equation numerically by using Scipy, in particular by the scipy.integrate.RK23 command. It returns <scipy.integrate._ivp.rk.RK23 at ...
3
votes
1answer
33 views

.std() & .skew() giving wrong answer with .rolling

I am using pandas version: '0.23.4' While debugging my code I realized that, std & skew is not giving correct results with rolling window. Check the code below: import pandas as pd import numpy ...
1
vote
3answers
27 views

Best way to create a three channel image with a fixed color?

I want to create a numpy three channel image with dimensions 10x5 and a fixed color of [0, 1, 2]. I'm currently doing it using the following code: x = np.array([0, 1, 2]) x = np.array((x,) * 10) x = ...
1
vote
2answers
32 views

Creating sample from custom distribution using scipy

I am trying to get some sample from a given distribution, in fact, it is a 3-parameter Pareto distribution. Here are the codes: from scipy.stats import gamma, rv_continuous class pareto3_pdf(...
1
vote
1answer
50 views

A three-parameter Pareto distribution in scipy.stats

I am trying to define a Pareto distribution using scipy.stats.pareto, but the model I am using is in a quite different form which has three parameter, where f(x) = (gamma(alpha + k) * lambda**alpha * ...
1
vote
1answer
27 views

Solving under-determined system of equations and constraints with Sympy and Scipy

I'm working on a python script that will help with annual portfolio rebalancing. For those of you unfamiliar with the concept, it basically means annually buying/selling assets that have gained/lost ...
0
votes
0answers
12 views

python why compute the mean in this case?

I have been trying to understand the caveats of the following code for plotting images of a scipy dataset: def plot_faces(images, n_row=2, n_col=5): """Helper function to plot a gallery of ...
0
votes
1answer
94 views

Solve non linear equation numpy

Edit: I want to solve this equation: 0=TR+(Tpow-T1)*(1-np.exp(h**2*alfa*t/k**2)+2/(3*np.sqrt(3))*h**3*(alfa*t)**(3/2)/k**3) Tpow,T1,alfa,t,k =constant h=? consider that TR is an 2D array Has ...