scipy

Python Distribution Fitting with Sum of Square Error (SSE)

女生的网名这么多〃 提交于 2021-01-05 08:55:52
问题 I am trying to find an optimal distribution curve fit to my data consisting of y-axis = [0, 0, 0, 0, 0.24, 0.53, 0.49, 0.64, 0.54, 0.78, 0.59, 0.44, 0.34, 0.88, 0.2, 0.49, 0.39, 0.39, 0.29, 0.2, 0.05, 0.05, 0.25, 0.05, 0.1, 0.15, 0.1, 0.1, 0.1, 0, 0, 0, 0, 0] y-axis are probabilities of an event occurring in x-axis time bins: x-axis = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0,

How to use Numba to speed up sparse linear system solvers in Python that are provided in scipy.sparse.linalg?

别来无恙 提交于 2021-01-05 07:33:43
问题 I wish to speed up the sparse system solver part of my code using Numba. Here is what I have up till now: # Both numba and numba-scipy packages are installed. I am using PyCharm IDE import numba import numba_scipy # import other required stuff @numba.jit(nopython=True) def solve_using_numba(A, b): return sp.linalg.gmres(A, b) # total = the number of points in the system A = sp.lil_matrix((total, total), dtype=float) # populate A with appropriate data A = A.tocsc() b = np.zeros((total, 1),

scipy curve_fit raises “OptimizeWarning: Covariance of the parameters could not be estimated”

孤街浪徒 提交于 2021-01-04 02:38:46
问题 I am trying to fit this function to some data: But when I use my code import numpy as np from scipy.optimize import curve_fit import matplotlib.pyplot as plt def f(x, start, end): res = np.empty_like(x) res[x < start] =-1 res[x > end] = 1 linear = np.all([[start <= x], [x <= end]], axis=0)[0] res[linear] = np.linspace(-1., 1., num=np.sum(linear)) return res if __name__ == '__main__': xdata = np.linspace(0., 1000., 1000) ydata = -np.ones(1000) ydata[500:1000] = 1. ydata = ydata + np.random

Plotting two variables then coloring by a third variable

不打扰是莪最后的温柔 提交于 2021-01-04 02:36:09
问题 I have a dataset from an aircraft flight and I am trying to plot the position of the plane (longitude x latitude) then color that line by the altitude of the plan at those coordinates. My code looks like this: lat_data = np.array( [ 39.916294, 39.87139 , 39.8005 , 39.70801 , 39.64645 , 39.58172 , 39.537853, 39.55141 , 39.6787 , 39.796528, 39.91702 , 40.008347, 40.09513 , 40.144157, 40.090584, 39.96447 , 39.838924, 39.712112, 39.597103, 39.488377, 39.499096, 39.99354 , 40.112175, 39.77281 , 39

Plotting two variables then coloring by a third variable

醉酒当歌 提交于 2021-01-04 02:35:26
问题 I have a dataset from an aircraft flight and I am trying to plot the position of the plane (longitude x latitude) then color that line by the altitude of the plan at those coordinates. My code looks like this: lat_data = np.array( [ 39.916294, 39.87139 , 39.8005 , 39.70801 , 39.64645 , 39.58172 , 39.537853, 39.55141 , 39.6787 , 39.796528, 39.91702 , 40.008347, 40.09513 , 40.144157, 40.090584, 39.96447 , 39.838924, 39.712112, 39.597103, 39.488377, 39.499096, 39.99354 , 40.112175, 39.77281 , 39

Scipy Optimize is only returning x0, only completing one iteration

青春壹個敷衍的年華 提交于 2021-01-03 06:12:39
问题 I am using scipy optimize to get the minimum value on the following function: def randomForest_b(a,b,c,d,e): return abs(rf_diff.predict([[a,b,c,d,e]])) I eventually want to be able to get the optimal values of (a) and (b) given the arguments (c,d,e). However, just to learn how to work the optimize function, I am trying to get the optimal value of (a) given the other arguments. I have the following code: res=optimize.minimize(randomForest_b, x0=45,args=(119.908500,65.517527,2.766103,29.509200)

Scipy Optimize is only returning x0, only completing one iteration

半世苍凉 提交于 2021-01-03 06:12:19
问题 I am using scipy optimize to get the minimum value on the following function: def randomForest_b(a,b,c,d,e): return abs(rf_diff.predict([[a,b,c,d,e]])) I eventually want to be able to get the optimal values of (a) and (b) given the arguments (c,d,e). However, just to learn how to work the optimize function, I am trying to get the optimal value of (a) given the other arguments. I have the following code: res=optimize.minimize(randomForest_b, x0=45,args=(119.908500,65.517527,2.766103,29.509200)

griddata scipy interpolation not working (giving nan)

流过昼夜 提交于 2021-01-02 08:34:24
问题 I was trying out the 2d example given in the scipy.interpolation.griddata help file. It works for interpolation with 'nearest'. But it gives a matrix filled with nan while using any other interpolation like 'linear' or 'cubic'. If I give the argument fill_value=5 , it gives the matrix filled with 5. Is this due to some installation problem? I was trying the exact same thing they have given in the help document. But somehow it is giving the result as if the points i asked to interpolating is

griddata scipy interpolation not working (giving nan)

南楼画角 提交于 2021-01-02 08:32:48
问题 I was trying out the 2d example given in the scipy.interpolation.griddata help file. It works for interpolation with 'nearest'. But it gives a matrix filled with nan while using any other interpolation like 'linear' or 'cubic'. If I give the argument fill_value=5 , it gives the matrix filled with 5. Is this due to some installation problem? I was trying the exact same thing they have given in the help document. But somehow it is giving the result as if the points i asked to interpolating is

calculating FFT in frames and writing to a file

烂漫一生 提交于 2021-01-01 13:52:45
问题 I'm new to python,I'm trying get a FFT value of a uploaded wav file and return the FFT of each frame in each line of a text file (using GCP) using scipy or librosa Frame rate i require is 30fps wave file will be of 48k sample rate so my questions are how do i divide the samples for the whole wav file into samples of each frame How do add empty samples to make the length of the frame samples power of 2 (as 48000/30 = 1600 add 448 empty samples to make it 2048) how do i normalize the resulting