Questions tagged [scipy]

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

SciPy is an open-source library for the programming language consisting of mathematical algorithms and functions for manipulating and visualizing data, often used in science and engineering. SciPy includes algorithms and tools for tasks such as optimization, clustering, discrete Fourier transforms, linear algebra, signal processing and multi-dimensional image processing.

SciPy is closely related to NumPy and depends on many functions, including a multidimensional array that is used as the basic data structure in SciPy.

SciPy is currently distributed under the BSD license.

Latest stable version:

1.7.3 (2021-11-25)

Documentation:

https://docs.scipy.org/doc/scipy/reference/

21123 questions
110
votes
3 answers

Two-sample Kolmogorov-Smirnov Test in Python Scipy

I can't figure out how to do a Two-sample KS test in Scipy. After reading the documentation of scipy kstest, I can see how to test whether a distribution is identical to standard normal distribution from scipy.stats import kstest import numpy as…
Akavall
  • 82,592
  • 51
  • 207
  • 251
107
votes
1 answer

Creating lowpass filter in SciPy - understanding methods and units

I am trying to filter a noisy heart rate signal with python. Because heart rates should never be above about 220 beats per minute, I want to filter out all noise above 220 bpm. I converted 220/minute into 3.66666666 Hertz and then converted that…
user3123955
  • 2,809
  • 6
  • 20
  • 21
107
votes
3 answers

How to implement band-pass Butterworth filter with Scipy.signal.butter

UPDATE: I found a Scipy Recipe based in this question! So, for anyone interested, go straight to: Contents » Signal processing » Butterworth Bandpass I'm having a hard time to achieve what seemed initially a simple task of implementing a…
heltonbiker
  • 26,657
  • 28
  • 137
  • 252
106
votes
3 answers

How to calculate the inverse of the normal cumulative distribution function in python?

How do I calculate the inverse of the cumulative distribution function (CDF) of the normal distribution in Python? Which library should I use? Possibly scipy?
Yueyoum
  • 2,823
  • 5
  • 23
  • 26
103
votes
8 answers

How to delete columns in numpy.array

I would like to delete selected columns in a numpy.array . This is what I do: n [397]: a = array([[ NaN, 2., 3., NaN], .....: [ 1., 2., 3., 9]]) In [398]: print a [[ NaN 2. 3. NaN] [ 1. 2. 3. 9.]] In [399]: z =…
Boris Gorelik
  • 29,945
  • 39
  • 128
  • 170
102
votes
5 answers

How to check the version of scipy

How can I check the version of scipy installed on my system?
OD IUM
  • 1,555
  • 2
  • 16
  • 26
100
votes
11 answers

How to make scipy.interpolate give an extrapolated result beyond the input range?

I'm trying to port a program which uses a hand-rolled interpolator (developed by a mathematician colleage) over to use the interpolators provided by scipy. I'd like to use or wrap the scipy interpolator so that it has as close as possible behavior…
Salim Fadhley
  • 22,020
  • 23
  • 75
  • 102
100
votes
3 answers

How do you find the IQR in Numpy?

Is there a baked-in Numpy/Scipy function to find the interquartile range? I can do it pretty easily myself, but mean() exists which is basically sum/len... def IQR(dist): return np.percentile(dist, 75) - np.percentile(dist, 25)
Nick T
  • 25,754
  • 12
  • 83
  • 121
100
votes
4 answers

shuffle vs permute numpy

What is the difference between numpy.random.shuffle(x) and numpy.random.permutation(x)? I have read the doc pages but I could not understand if there was any difference between the two when I just want to randomly shuffle the elements of an…
DotPi
  • 3,977
  • 6
  • 33
  • 53
95
votes
10 answers

Save / load scipy sparse csr_matrix in portable data format

How do you save/load a scipy sparse csr_matrix in a portable format? The scipy sparse matrix is created on Python 3 (Windows 64-bit) to run on Python 2 (Linux 64-bit). Initially, I used pickle (with protocol=2 and fix_imports=True) but this didn't…
Henry Thornton
  • 4,381
  • 9
  • 36
  • 43
93
votes
9 answers

ImportError: cannot import name NUMPY_MKL

I am trying to run the following simple code import scipy scipy.test() But I am getting the following error Traceback (most recent call last): File "", line 1, in File…
Steve
  • 1,178
  • 1
  • 7
  • 18
90
votes
11 answers

Find out if matrix is positive definite with numpy

I need to find out if matrix is positive definite. My matrix is numpy matrix. I was expecting to find any related method in numpy library, but no success. I appreciate any help.
Zygimantas Gatelis
  • 1,923
  • 2
  • 18
  • 27
90
votes
6 answers

Resampling a numpy array representing an image

I am looking for how to resample a numpy array representing image data at a new size, preferably having a choice of the interpolation method (nearest, bilinear, etc.). I know there is scipy.misc.imresize which does exactly this by wrapping PIL's…
Gustav Larsson
  • 8,199
  • 3
  • 31
  • 51
89
votes
9 answers

How to solve a pair of nonlinear equations using Python?

What's the (best) way to solve a pair of non linear equations using Python. (Numpy, Scipy or Sympy) eg: x+y^2 = 4 e^x+ xy = 3 A code snippet which solves the above pair will be great
AIB
  • 5,894
  • 8
  • 30
  • 36
88
votes
6 answers

sparse 3d matrix/array in Python?

In scipy, we can construct a sparse matrix using scipy.sparse.lil_matrix() etc. But the matrix is in 2d. I am wondering if there is an existing data structure for sparse 3d matrix / array (tensor) in Python? p.s. I have lots of sparse data in 3d and…
zhongqi
  • 1,127
  • 2
  • 11
  • 11