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
51
votes
5 answers

Convert an image RGB->Lab with python

What is the preferred way of doing the conversion using PIL/Numpy/SciPy today?
Antony Hatchkins
  • 31,947
  • 10
  • 111
  • 111
50
votes
11 answers

Invertible STFT and ISTFT in Python

Is there any general-purpose form of short-time Fourier transform with corresponding inverse transform built into SciPy or NumPy or whatever? There's the pyplot specgram function in matplotlib, which calls ax.specgram(), which calls mlab.specgram(),…
endolith
  • 25,479
  • 34
  • 128
  • 192
50
votes
4 answers

Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000

I want to make an logharitmic fit. But I keep getting the a runtime error: Optimal parameters not found: Number of calls to function has reached maxfev = 1000 I use the following script. Can anyone tell me where I go wrong? I use Spyder an am…
Tjitze
  • 501
  • 1
  • 4
  • 3
50
votes
7 answers

P-value from Chi sq test statistic in Python

I have computed a test statistic that is distributed as a chi square with 1 degree of freedom, and want to find out what P-value this corresponds to using python. I'm a python and maths/stats newbie so I think what I want here is the probability…
Davy Kavanagh
  • 4,809
  • 9
  • 35
  • 50
49
votes
6 answers

Efficient method of calculating density of irregularly spaced points

I am attempting to generate map overlay images that would assist in identifying hot-spots, that is areas on the map that have high density of data points. None of the approaches that I've tried are fast enough for my needs. Note: I forgot to mention…
Ivo Bosticky
  • 6,338
  • 6
  • 34
  • 35
49
votes
3 answers

Inverse Distance Weighted (IDW) Interpolation with Python

The Question: What is the best way to calculate inverse distance weighted (IDW) interpolation in Python, for point locations? Some Background: Currently I'm using RPy2 to interface with R and its gstat module. Unfortunately, the gstat module…
Michael Allan Jackson
  • 4,217
  • 3
  • 35
  • 45
49
votes
1 answer

How to use numpy.void type

I loaded a MATLAB .mat file via scipy.io.loadmat and it gave me a list of numpy.void objects. What are they, how can they be used and where can I get some reference documentation on them?
Felix
  • 3,351
  • 6
  • 40
  • 68
49
votes
6 answers

Calculate the Cumulative Distribution Function (CDF) in Python

How can I calculate in python the Cumulative Distribution Function (CDF)? I want to calculate it from an array of points I have (discrete distribution), not with the continuous distributions that, for example, scipy has.
wizbcn
  • 1,064
  • 1
  • 12
  • 19
49
votes
1 answer

Concatenate sparse matrices in Python using SciPy/Numpy

What would be the most efficient way to concatenate sparse matrices in Python using SciPy/Numpy? Here I used the following: >>> np.hstack((X, X2)) array([ <49998x70000 sparse matrix of type '' with 1135520 stored…
PascalVKooten
  • 20,643
  • 17
  • 103
  • 160
49
votes
5 answers

Python finite difference functions?

I've been looking around in Numpy/Scipy for modules containing finite difference functions. However, the closest thing I've found is numpy.gradient(), which is good for 1st-order finite differences of 2nd order accuracy, but not so much if you're…
Tim Supinie
  • 983
  • 1
  • 9
  • 9
49
votes
2 answers

Scipy Normaltest how is it used?

I need to use normaltest in scipy for testing if the dataset is normal distributet. But I cant seem to find any good examples how to use scipy.stats.normaltest. My dataset has more than 100 values.
The Demz
  • 7,066
  • 5
  • 39
  • 43
48
votes
9 answers

How to read images into a script without using using imageio or scikit image?

I am trying to read a png image in python. The imread function in scipy is being deprecated and they recommend using imageio library. However, I am would rather restrict my usage of external libraries to scipy, numpy and matplotlib libraries. Thus,…
Gerges
  • 6,269
  • 2
  • 22
  • 44
48
votes
3 answers

Using a sparse matrix versus numpy array

I am creating some numpy arrays with word counts in Python: rows are documents, columns are counts for word X. If I have a lot of zero counts, people suggest using sparse matrices when processing these further, e.g. in a classifier. When feeding a…
patrick
  • 4,455
  • 6
  • 44
  • 61
48
votes
2 answers

Plot Normal distribution with Matplotlib

please help me to plot the normal distribution of the folowing data: DATA: import numpy as np import matplotlib.pyplot as plt from scipy.stats import norm h = [186, 176, 158, 180, 186, 168, 168, 164, 178, 170, 189, 195, 172, 187, 180, 186,…
Adel
  • 3,542
  • 8
  • 30
  • 31
48
votes
10 answers

How to specify upper and lower limits when using numpy.random.normal

I want to be able to pick values from a normal distribution that only ever fall between 0 and 1. In some cases I want to be able to basically just return a completely random distribution, and in other cases I want to return values that fall in the…
Catherine Georgia
  • 879
  • 3
  • 13
  • 17