scipy

How to organize list of list of lists to be compatible with scipy.optimize fmin init array

久未见 提交于 2021-02-11 13:27:18
问题 I am very amateur when it comes to scipy. I am trying to use scipy's fmin function on a multidimensional variable system. For the sake of simplicity I am using list of list of list's. My data is 12 dimensional, when I enter np.shape(DATA) it returns (3,2,2) , I am not even sure if scipy can handle that many dimensions, if not no problem I can reduce them, the point is that the optimize.fmin() function doesn't accept list based arrays as x0 initial parameters, so I need help either rewriting

Find all shortest Euclidean distances between two groups of point coordinates

左心房为你撑大大i 提交于 2021-02-11 13:15:05
问题 I have a Pandas DataFrame, where columns X1, Y1 have point coordinates for the first group of coordinates and columns X2, Y2 have point coordinates for the second group of coordinates. Both groups are independent of each other. It is just happen to be they are in the same dataframe. Example: X1,Y1,X2,Y2 41246.438,0.49,38791.673,0.49 41304.5,0.491,38921.557,0.491 41392.062,0.492,39037.135,0.492 41515.5,0.493,39199.972,0.493 41636.062,0.494,39346.561,0.494 41795.188,0.495,39477.63,0.495 42027

Find all shortest Euclidean distances between two groups of point coordinates

旧巷老猫 提交于 2021-02-11 13:12:20
问题 I have a Pandas DataFrame, where columns X1, Y1 have point coordinates for the first group of coordinates and columns X2, Y2 have point coordinates for the second group of coordinates. Both groups are independent of each other. It is just happen to be they are in the same dataframe. Example: X1,Y1,X2,Y2 41246.438,0.49,38791.673,0.49 41304.5,0.491,38921.557,0.491 41392.062,0.492,39037.135,0.492 41515.5,0.493,39199.972,0.493 41636.062,0.494,39346.561,0.494 41795.188,0.495,39477.63,0.495 42027

How to resample a .wav sound file which is being read using the wavfile.read?

﹥>﹥吖頭↗ 提交于 2021-02-11 12:54:25
问题 I want to change the following two lines of my code: clip, sample_rate = librosa.load(file_name) clip = librosa.resample(clip, sample_rate, 2000) I want to load the .wav file using wavfile.read() instead of using librosa.load() and then resample it using some technique other than the libroa.resample() . Any idea how to do it? 回答1: So here is the answer folks! The below solution worked for me. from scipy.io import wavfile import scipy.signal as sps from io import BytesIO new_rate = 2000 # Read

How can I change the number of basis functions when performing B-Spline fitting in scipy (python)?

风流意气都作罢 提交于 2021-02-11 12:23:56
问题 I have a discrete set of points (x_n, y_n) that I would like to approximate/represent as a linear combination of B-spline basis functions. I need to be able to manually change the number of B-spline basis functions used by the method, and I am trying to implement this in python using scipy. To be specific, below is a bit of code that I am using: import scipy spl = scipy.interpolate.splrep(x, y) However, unless I have misunderstood or missed something in the documentation, it seems I cannot

“ImportError: DLL load failed: The specified module could not be found” when trying to import gensim

风流意气都作罢 提交于 2021-02-11 12:20:19
问题 While trying to import gensim, I run into the following error Traceback (most recent call last): File "c:\Users\usr\Documents\hello\test.py", line 3, in <module> import gensim File "C:\Users\usr\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\gensim\__init__.py", line 5, in <module> from gensim import parsing, corpora, matutils, interfaces, models, similarities, summarization, utils # noqa:F401 File "C:\Users\usr

efficient way of constructing a matrix of pair-wise distances between many vectors?

限于喜欢 提交于 2021-02-11 08:10:37
问题 First, thanks for reading and taking the time to respond. Second, the question: I have a PxN matrix X where P is in the order of 10^6 and N is in the order of 10^3. So, X is relatively large and is not sparse. Let's say each row of X is an N-dimensional sample. I want to construct a PxP matrix of pairwise distances between these P samples. Let's also say I am interested in Hellinger distances. So far I am relying on sparse dok matrices: def hellinger_distance(X): P = X.shape[0] H1 = sp.sparse

How to extract the function model (polynomials) from scipy.interpolate.splprep()?

不问归期 提交于 2021-02-10 22:10:57
问题 I now have some discrete points, and I interpolated it using the scipy.interpolate.splprep () function (B-spline interpolation) to get a satisfactory smooth curve. Here's the code (draw on the answer to another question) and the result I got. import numpy as np from scipy import interpolate from matplotlib import pyplot as plt # x and y are points sampled randomly x = sampledx y = sampledy # append the starting x,y coordinates x = np.r_[x, x[0]] y = np.r_[y, y[0]] # fit splines to x=f(u) and

Solving a system of 2nd order differential equations from sympy

。_饼干妹妹 提交于 2021-02-10 14:50:39
问题 I am doing a multiple DOF dynamics problem, using 2nd order Lagrangian equations. I used sympy to get to the equations of motion. Now these equations after calculating the derivatives got quite long, seems though that sympy simplify cant simplify it further. My problem actually is how to solve this system of three 2nd order ode from here. I don't know how to get these equations converted so they can be used with scipy.odeint(). Substitution came to mind, but there are a lot of symbols. So Im