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
192
votes
13 answers

Fitting empirical distribution to theoretical ones with Scipy (Python)?

INTRODUCTION: I have a list of more than 30,000 integer values ranging from 0 to 47, inclusive, e.g.[0,0,0,0,..,1,1,1,1,...,2,2,2,2,...,47,47,47,...] sampled from some continuous distribution. The values in the list are not necessarily in order, but…
s_sherly
  • 2,307
  • 4
  • 19
  • 14
191
votes
30 answers

ERROR: Could not build wheels for scipy which use PEP 517 and cannot be installed directly

I'm trying to install scipy via pip on my 64 bit ARMV8 board. I have already installed openblas which is required by scipy. So, no issues with that. When i gave pip3 install scipy --trusted-host pypi.org --trusted-host files.pythonhosted.org , I got…
Sourabrt
  • 2,126
  • 2
  • 8
  • 22
189
votes
10 answers

Numpy Resize/Rescale Image

I would like to take an image and change the scale of the image, while it is a numpy array. For example I have this image of a coca-cola bottle: bottle-1 Which translates to a numpy array of shape (528, 203, 3) and I want to resize that to say the…
Brian Hamill
  • 2,466
  • 4
  • 12
  • 20
186
votes
10 answers

Peak-finding algorithm for Python/SciPy

I can write something myself by finding zero-crossings of the first derivative or something, but it seems like a common-enough function to be included in standard libraries. Anyone know of one? My particular application is a 2D array, but usually…
endolith
  • 25,479
  • 34
  • 128
  • 192
185
votes
2 answers

How do I use numpy.where()? What should I pass, and what does the result mean?

I tried reading the documentation for numpy.where(), but I'm still confused. What should I pass for the condition, x and y values? When I pass only condition, what does the result mean and how can I use it? What about when I pass all three? I found…
Alexandre Holden Daly
  • 6,944
  • 5
  • 25
  • 36
185
votes
6 answers

Numpy: Divide each row by a vector element

Suppose I have a numpy array: data = np.array([[1,1,1],[2,2,2],[3,3,3]]) and I have a corresponding "vector:" vector = np.array([1,2,3]) How do I operate on data along each row to either subtract or divide so the result is: sub_result = [[0,0,0],…
BFTM
  • 3,225
  • 6
  • 23
  • 22
184
votes
7 answers

Does Python SciPy need BLAS?

numpy.distutils.system_info.BlasNotFoundError: Blas (http://www.netlib.org/blas/) libraries not found. Directories to search for the libraries can be specified in the numpy/distutils/site.cfg file (section [blas]) or by setting the…
joedborg
  • 17,651
  • 32
  • 84
  • 118
181
votes
6 answers

Compute a confidence interval from sample data

I have sample data which I would like to compute a confidence interval for, assuming a normal distribution. I have found and installed the numpy and scipy packages and have gotten numpy to return a mean and standard deviation (numpy.mean(data) with…
Bmayer0122
  • 2,138
  • 2
  • 14
  • 7
179
votes
18 answers

scipy.misc module has no attribute imread?

I am trying to read an image with scipy. However it does not accept the scipy.misc.imread part. What could be the cause of this? >>> import scipy >>> scipy.misc >>>…
ustroetz
  • 5,802
  • 16
  • 47
  • 74
176
votes
2 answers

A tool to convert MATLAB code to Python

I have a bunch of MATLAB code from my MS thesis which I now want to convert to Python (using numpy/scipy and matplotlib) and distribute as open-source. I know the similarity between MATLAB and Python scientific libraries, and converting them…
Jack_of_All_Trades
  • 10,942
  • 18
  • 58
  • 88
172
votes
3 answers

Should I use scipy.pi, numpy.pi, or math.pi?

In a project using SciPy and NumPy, should I use scipy.pi, numpy.pi, or math.pi?
Douglas B. Staple
  • 10,510
  • 8
  • 31
  • 58
161
votes
8 answers

Installing SciPy and NumPy using pip

I'm trying to create required libraries in a package I'm distributing. It requires both the SciPy and NumPy libraries. While developing, I installed both using apt-get install scipy which installed SciPy 0.9.0 and NumPy 1.5.1, and it worked fine. I…
eran
  • 14,496
  • 34
  • 98
  • 144
159
votes
6 answers

How to create a density plot

In R I can create the desired output by doing: data = c(rep(1.5, 7), rep(2.5, 2), rep(3.5, 8), rep(4.5, 3), rep(5.5, 1), rep(6.5, 8)) plot(density(data, bw=0.5)) In python (with matplotlib) the closest I got was with a simple…
unode
  • 9,321
  • 4
  • 33
  • 44
153
votes
15 answers

Multiple linear regression in Python

I can't seem to find any python libraries that do multiple regression. The only things I find only do simple regression. I need to regress my dependent variable (y) against several independent variables (x1, x2, x3, etc.). For example, with this…
Zach
  • 4,624
  • 13
  • 43
  • 60
148
votes
3 answers

Confusion between numpy, scipy, matplotlib and pylab

Numpy, scipy, matplotlib, and pylab are common terms among they who use python for scientific computation. I just learn a bit about pylab, and I got confused. Whenever I want to import numpy, I can always do: import numpy as np I just consider,…
goFrendiAsgard
  • 4,016
  • 8
  • 38
  • 64