scipy

ValueError: Domain error in arguments scipy rv_continuous

会有一股神秘感。 提交于 2021-01-29 03:17:04
问题 I was trying to sample random variables subject to a given probability density function (pdf) with scipy.stats.rv_continuous: class Distribution(stats.rv_continuous): def _pdf(self,x, _a, _c): return first_hitting_time(x, _a, _c) where the function first_hitting_time is #pdf of first hitting time of W_t + c*t on a. def first_hitting_time(_t, _a, _c=0.0): return _a/_t*np.exp(-0.5/_t*(_a-_c*_t)**2)/np.sqrt(2.0*np.pi*_t) then I continue with myrv= Distribution(name='hittingtime', a=0.002,b=30.0)

ValueError: The array returned by a function changed size between calls scipy.fsolve()

牧云@^-^@ 提交于 2021-01-29 02:32:37
问题 I am trying to use scipy.optimize.fsolve() to solve for x that makes the function equal to zero, but keep getting the error above. My code is: import scipy.optimize as optimize from scipy.stats import genextreme as gev gevcombined = [(-0.139, 3.035, 0.871),(-0.0863, 3.103, 0.818),(-0.198, 3.13, 0.982)] ratio = [0.225, 0.139, 0.294] P = [0.5,0.8,0.9,0.96,0.98,0.99] def mixedpop(x): for j in range(len(ratio)): F = (ratio[j]*gev.cdf(x,gevcombined[j][0],gevcombined[j][1],gevcombined[j][2]))+((1

ValueError: The array returned by a function changed size between calls scipy.fsolve()

旧城冷巷雨未停 提交于 2021-01-29 02:29:47
问题 I am trying to use scipy.optimize.fsolve() to solve for x that makes the function equal to zero, but keep getting the error above. My code is: import scipy.optimize as optimize from scipy.stats import genextreme as gev gevcombined = [(-0.139, 3.035, 0.871),(-0.0863, 3.103, 0.818),(-0.198, 3.13, 0.982)] ratio = [0.225, 0.139, 0.294] P = [0.5,0.8,0.9,0.96,0.98,0.99] def mixedpop(x): for j in range(len(ratio)): F = (ratio[j]*gev.cdf(x,gevcombined[j][0],gevcombined[j][1],gevcombined[j][2]))+((1

ValueError: The array returned by a function changed size between calls scipy.fsolve()

谁都会走 提交于 2021-01-29 02:25:58
问题 I am trying to use scipy.optimize.fsolve() to solve for x that makes the function equal to zero, but keep getting the error above. My code is: import scipy.optimize as optimize from scipy.stats import genextreme as gev gevcombined = [(-0.139, 3.035, 0.871),(-0.0863, 3.103, 0.818),(-0.198, 3.13, 0.982)] ratio = [0.225, 0.139, 0.294] P = [0.5,0.8,0.9,0.96,0.98,0.99] def mixedpop(x): for j in range(len(ratio)): F = (ratio[j]*gev.cdf(x,gevcombined[j][0],gevcombined[j][1],gevcombined[j][2]))+((1

Convert array of lists to array of tuples/triple

跟風遠走 提交于 2021-01-29 01:55:37
问题 I have a 2D Numpy array with 3 columns. It looks something like this array([[0, 20, 1], [1,2,1], ........, [20,1,1]]) . It basically is array of list of lists. How can I convert this matrix into array([(0,20,1), (1,2,1), ........., (20,1,1)]) ? I want the output to be a array of triple. I have been trying to use tuple and map functions described in Convert numpy array to tuple, R = mydata #my data is sparse matrix of 1's and 0's #First row #R[0] = array([0,0,1,1]) #Just a sample (rows, cols)

Print highest peak value of the frequency domain plot

不羁岁月 提交于 2021-01-28 20:45:01
问题 I've attempted to plot the oscillations of my home made quad in the time and frequency domain. How do I print the value of my highest peak in the frequency domain plot? code: import matplotlib.pyplot as plt import numpy as np from scipy import fft, arange csv = np.genfromtxt ('/Users/shaunbarney/Desktop/Results/quadOscillations.csv', delimiter=",",dtype=float) x = csv[:,0] y = csv[:,1] x = x - 6318 #Remove start offset av=0 for i in xrange(1097): #Calculate average sampling time in seconds

DLL load failed: The specified module could not be found while importing scipy

∥☆過路亽.° 提交于 2021-01-28 14:00:37
问题 I have installed python with Anaconda on windows 10. I have created a virtual environment with Anaconda called venv . After activating the environment, >>>python gives: Python 3.6.8 |Anaconda, Inc.| (default, Feb 11 2019, 15:03:47) [MSC v.1915 64 bit (AMD64)] on win32 I have installed scipy in my venv using pip: pip install scipy . I have set the interpreter in pycharm to the venv python interpreter. Now, I tried the following in a new module in pycharm: import scipy # No error here from

`f0` passed has more than 1 dimension. - fmin_l_bfgs_b

心已入冬 提交于 2021-01-28 11:48:17
问题 I want to find parameters which minimalize a function but I get an error. So far use scipy.optimize.fmin but I want to add bounds for every argument. This is my code def Kou_calibration_full(): i=0 global opt p0 = spo.brute(Kou_error_function, ((0.10,0.31, 0.1),(0.01,2.6, 0.5), (0.1,0.92,0.2), (1.1,20,7),(0.1,20,7)), finish=None) opt = spo.minimize(Kou_error_function, p0, bounds=((0.10,0.31),(0.01,2.6), (0.1,0.92), (1.1,20),(0.1,20))) return opt -----------------------------------------------

Keep getting this error using numpy.piecewise to get segmented linear regression

孤街浪徒 提交于 2021-01-28 11:00:28
问题 I have a very large datafile, where x= time and y= distance. I would like to figure out what the speed is in different segments. Ideally, I would like Python to calculate the segments and the corresponding linear regression functions. I googled this and think my best option is using the numpy.piecewise to get segmented linear regression. I only keep getting this error # Remove full_output from kwargs, otherwise we're passing it in twice'. The code is use is as follows: y = cleandata["Distance

Python import error “getfullargspec”

一曲冷凌霜 提交于 2021-01-28 07:34:59
问题 when I do: from sklearn import linear_model I get the error: ImportError: cannot import name 'getfullargspec' Interestingly, this does not happen a few days ago. So I tried to install python and scipy stack again on my computer using Anaconda again but does not solve the problem. What might be wrong with my system? Thank you in advance. 回答1: Install using pip pip install scipy And use pip to install the following packages such as numpy, pandas, etc... If you are using Python 3 then install