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
142
votes
6 answers

binning data in python with scipy/numpy

is there a more efficient way to take an average of an array in prespecified bins? for example, i have an array of numbers and an array corresponding to bin start and end positions in that array, and I want to just take the mean in those bins? I…
user248237
140
votes
5 answers

How to check BLAS/LAPACK linkage in NumPy and SciPy?

I am builing my numpy/scipy environment based on blas and lapack more or less based on this walk through. When I am done, how can I check, that my numpy/scipy functions really do use the previously built blas/lapack functionalities?
Woltan
  • 13,723
  • 15
  • 78
  • 104
136
votes
8 answers

How to calculate cumulative normal distribution?

I am looking for a function in Numpy or Scipy (or any rigorous Python library) that will give me the cumulative normal distribution function in Python.
toma
136
votes
20 answers

Can't install Scipy through pip

When installing scipy through pip with : pip install scipy Pip fails to build scipy and throws the following error: Cleaning up... Command /Users/administrator/dev/KaggleAux/env/bin/python2.7 -c "import setuptools,…
agconti
  • 17,780
  • 15
  • 80
  • 114
132
votes
13 answers

ImportError in importing from sklearn: cannot import name check_build

I am getting the following error while trying to import from sklearn: >>> from sklearn import svm Traceback (most recent call last): File "", line 1, in from sklearn import svm File…
ayush singhal
  • 1,879
  • 2
  • 18
  • 33
131
votes
7 answers

Plotting a fast Fourier transform in Python

I have access to NumPy and SciPy and want to create a simple FFT of a data set. I have two lists, one that is y values and the other is timestamps for those y values. What is the simplest way to feed these lists into a SciPy or NumPy method and plot…
user3123955
  • 2,809
  • 6
  • 20
  • 21
127
votes
3 answers

How to get the indices list of all NaN value in numpy array?

Say now I have a numpy array which is defined as, [[1,2,3,4], [2,3,NaN,5], [NaN,5,2,3]] Now I want to have a list that contains all the indices of the missing values, which is [(1,2),(2,0)] at this case. Is there any way I can do that?
xxx222
  • 2,980
  • 5
  • 34
  • 53
122
votes
1 answer

How can I perform two-dimensional interpolation using scipy?

This Q&A is intended as a canonical(-ish) concerning two-dimensional (and multi-dimensional) interpolation using scipy. There are often questions concerning the basic syntax of various multidimensional interpolation methods, I hope to set these…
122
votes
10 answers

How to calculate probability in a normal distribution given mean & standard deviation?

How to calculate probability in normal distribution given mean, std in Python? I can always explicitly code my own function according to the definition like the OP in this question did: Calculating Probability of a Random Variable in a Distribution…
clwen
  • 20,004
  • 31
  • 77
  • 94
121
votes
7 answers

Histogram Matplotlib

So I have a little problem. I have a data set in scipy that is already in the histogram format, so I have the center of the bins and the number of events per bin. How can I now plot is as a histogram. I tried just doing bins, n=hist() but it…
madtowneast
  • 2,350
  • 3
  • 22
  • 31
115
votes
11 answers

Principal component analysis in Python

I'd like to use principal component analysis (PCA) for dimensionality reduction. Does numpy or scipy already have it, or do I have to roll my own using numpy.linalg.eigh? I don't just want to use singular value decomposition (SVD) because my input…
Vebjorn Ljosa
  • 17,438
  • 13
  • 70
  • 88
114
votes
13 answers

scipy: savefig without frames, axes, only content

In numpy/scipy I have an image stored in an array. I can display it, I want to save it using savefig without any borders, axes, labels, titles,... Just pure image, nothing else. I want to avoid packages like PyPNG or scipy.misc.imsave, they are…
Jakub M.
  • 32,471
  • 48
  • 110
  • 179
113
votes
17 answers

ImportError: No module named scipy

I am using Python 2.7 and trying to get PyBrain to work. But I get this error even though scipy is installed - Traceback (most recent call last): File "", line 1, in File…
ihmpall
  • 1,358
  • 2
  • 13
  • 17
112
votes
4 answers

How to transform numpy.matrix or array to scipy sparse matrix

For SciPy sparse matrix, one can use todense() or toarray() to transform to NumPy matrix or array. What are the functions to do the inverse? I searched, but got no idea what keywords should be the right hit.
Flake
  • 4,377
  • 6
  • 30
  • 29
111
votes
9 answers

Quantile-Quantile Plot using SciPy

How would you create a qq-plot using Python? Assuming that you have a large set of measurements and are using some plotting function that takes XY-values as input. The function should plot the quantiles of the measurements against the corresponding…
John
  • 1,721
  • 3
  • 15
  • 15