scipy

Checking if a point is in ConvexHull?

為{幸葍}努か 提交于 2021-02-10 08:44:45
问题 I am having trouble understanding how to compute whether an n-dimensional point is within an n-dimensional ConvexHull. A very similar question (the same) was asked here: What's an efficient way to find if a point lies in the convex hull of a point cloud? However, the answers are confusing me or don't seem to work for me, and I have no idea why. def in_hull(p, hull): """ Copied and from the Top Original answer """ from scipy.spatial import Delaunay if not isinstance(hull,Delaunay): hull =

Python- scipy ODR going crazy

。_饼干妹妹 提交于 2021-02-10 06:09:37
问题 I would like to use scipy's ODR to fit a curve to a set of variables with variances. In this case, I am fitting a linear function with a set Y axis crossing point (e.g. a*x+100 ). Due to my inability to find an estimator (I asked about that here), I am using scipy.optimize curve_fit to estimate the initial a value. Now, the function works perfectly without standard deviation, but when I add it, the output makes completely no sense (the curve is far above all of the points). What could be the

Least squares in a set of equations with optimize.leastsq() (Python)

陌路散爱 提交于 2021-02-09 15:49:04
问题 I have two functions and a set of data. Both functions have the same x data and the same parameters. I want to obtain the parameters by least squares method that makes the best fit of my data. The parameters are: ex,ey,ez. The X data are: RA,DE (like 3000 points). The Y data are: dRA,dDE. I tried this but I obtained a wrong solution: def residuals(p, dRA, dDE, RA, DEC): ex,ey,ez = p f1 = dRA-(ex*sin(DEC)*cos(RA)+ey*sin(DEC)*sin(RA)-ez*cos(DEC)) f2 = dDE-(-ex*sin(RA)+ey*cos(RA)) err = np

Least squares in a set of equations with optimize.leastsq() (Python)

人盡茶涼 提交于 2021-02-09 15:46:38
问题 I have two functions and a set of data. Both functions have the same x data and the same parameters. I want to obtain the parameters by least squares method that makes the best fit of my data. The parameters are: ex,ey,ez. The X data are: RA,DE (like 3000 points). The Y data are: dRA,dDE. I tried this but I obtained a wrong solution: def residuals(p, dRA, dDE, RA, DEC): ex,ey,ez = p f1 = dRA-(ex*sin(DEC)*cos(RA)+ey*sin(DEC)*sin(RA)-ez*cos(DEC)) f2 = dDE-(-ex*sin(RA)+ey*cos(RA)) err = np

Issues using the scipy.sparse.linalg linear system solvers

社会主义新天地 提交于 2021-02-08 15:25:37
问题 I've got linear system to solve which consists of large, sparse matrices. I've been using the scipy.sparse library, and its linalg sub-library to do this, but I can't get some of the linear solvers to work. Here is a working example which reproduces the issue for me: from numpy.random import random from scipy.sparse import csc_matrix from scipy.sparse.linalg import spsolve, minres N = 10 A = csc_matrix( random(size = (N,N)) ) A = (A.T).dot(A) # force the matrix to be symmetric, as required by

Getting the parameter names of scipy.stats distributions

无人久伴 提交于 2021-02-08 14:07:44
问题 I am writing a script to find the best-fitting distribution over a dataset using scipy.stats. I first have a list of distribution names, over which I iterate: dists = ['alpha', 'anglit', 'arcsine', 'beta', 'betaprime', 'bradford', 'norm'] for d in dists: dist = getattr(scipy.stats, d) ps = dist.fit(selected_data) errors.loc[d,['D-Value','P-Value']] = kstest(selected.tolist(), d, args=ps) errors.loc[d,'Params'] = ps Now, after this loop, I select the minimum D-Value in order to get the best

`ValueError: too many values to unpack (expected 4)` with `scipy.stats.linregress`

烈酒焚心 提交于 2021-02-08 13:47:15
问题 I know that this error message ( ValueError: too many values to unpack (expected 4) ) appears when more variables are set to values than a function returns. scipy.stats.linregress returns 5 values according to the scipy documentation (http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.linregress.html). Here is a short, reproducible example of a working call, and then a failed call, to linregress : What could account for difference and why is the second one poorly called? from

How to solve complex matrix differential equations using solve_ivp?

杀马特。学长 韩版系。学妹 提交于 2021-02-08 11:37:45
问题 I want to solve a complex matrix differential equation y' = Ay. import numpy as np from scipy.integrate import solve_ivp def deriv(y, t, A): return np.dot(A, y) A = np.array([[-0.25 + 0.14j, 0, 0.33 + 0.44j], [ 0.25 + 0.58j, -0.2 + 0.14j, 0], [ 0, 0.2 + 0.4j, -0.1 + 0.97j]]) time = np.linspace(0, 25, 101) y0 = np.array([[2, 3, 4], [5, 6 , 7], [9, 34, 78]]) result = solve_ivp(deriv, y0, time, args=(A,)) There already seems to be an answer in case of 'odeint'. https://stackoverflow.com/a

How to solve complex matrix differential equations using solve_ivp?

♀尐吖头ヾ 提交于 2021-02-08 11:37:07
问题 I want to solve a complex matrix differential equation y' = Ay. import numpy as np from scipy.integrate import solve_ivp def deriv(y, t, A): return np.dot(A, y) A = np.array([[-0.25 + 0.14j, 0, 0.33 + 0.44j], [ 0.25 + 0.58j, -0.2 + 0.14j, 0], [ 0, 0.2 + 0.4j, -0.1 + 0.97j]]) time = np.linspace(0, 25, 101) y0 = np.array([[2, 3, 4], [5, 6 , 7], [9, 34, 78]]) result = solve_ivp(deriv, y0, time, args=(A,)) There already seems to be an answer in case of 'odeint'. https://stackoverflow.com/a

scipy for ABAQUS on 64 bit Windows system

吃可爱长大的小学妹 提交于 2021-02-08 11:09:28
问题 I have a Python script, which is used in ABAQUS and calls numpy and scipy. I switched from a 32-bit Windows machine to a 64-bit machine. I have problems installing scipy for ABAQUS 6.13.1 on my new 64-bit system. Could anybody give me some tips on how to get scipy running for ABAQUS and provide me with the compatible version of scipy? Regards. 回答1: Download and Install a 64 bit version of Anaconda. https://store.continuum.io/cshop/anaconda/ Using Conda, downgrade the version of SciPy to be