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
35
votes
3 answers

In Scipy how and why does curve_fit calculate the covariance of the parameter estimates

I have been using scipy.optimize.leastsq to fit some data. I would like to get some confidence intervals on these estimates so I look into the cov_x output but the documentation is very unclear as to what this is and how to get the covariance matrix…
HansHarhoff
  • 1,917
  • 2
  • 22
  • 32
35
votes
10 answers

SciPy build/install Mac Osx

I successfully built/installed NumPy on my mac os x for python 2.7.3. Now I would like to build/install scipy as well. I downloaded it from git hub. Went into the directory. Ran python setup.py build and it seemed to be working until it came across…
Megan
  • 622
  • 1
  • 10
  • 16
34
votes
6 answers

python built-in function to do matrix reduction

Does python have a built-in function that converts a matrix into row echelon form (also known as upper triangular)?
user968102
  • 503
  • 2
  • 6
  • 11
34
votes
1 answer

Calling statistics functions from Scipy

This may well be completely trivial. I want to call the spearmanr function from scipy: (the data are just examples) import scipy from numpy import * Len = [2,3,5,7,2] Pop = [5,2,6,3,2] a = array(Len) b = array(Pop) print…
WillJones
  • 907
  • 1
  • 9
  • 19
34
votes
9 answers

fitting exponential decay with no initial guessing

Does anyone know a scipy/numpy module which will allow to fit exponential decay to data? Google search returned a few blog posts, for example - http://exnumerus.blogspot.com/2010/04/how-to-fit-exponential-decay-example-in.html , but that solution…
George Karpenkov
  • 2,094
  • 1
  • 16
  • 36
34
votes
5 answers

Reverse Box-Cox transformation

I am using SciPy's boxcox function to perform a Box-Cox transformation on a continuous variable. from scipy.stats import boxcox import numpy as np y = np.random.random(100) y_box, lambda_ = ss.boxcox(y + 1) # Add 1 to be able to transform 0…
Gyan Veda
  • 6,309
  • 11
  • 41
  • 66
34
votes
4 answers

How to select inverse of indexes of a numpy array?

I have a large set of data in which I need to compare the distances of a set of samples from this array with all the other elements of the array. Below is a very simple example of my data set. import numpy as np import scipy.spatial.distance as…
b10hazard
  • 7,399
  • 11
  • 40
  • 53
34
votes
5 answers

scipy is not optimizing and returns "Desired error not necessarily achieved due to precision loss"

I have the following code which attempts to minimize a log likelihood function. #!/usr/bin/python import math import random import numpy as np from scipy.optimize import minimize def loglikelihood(params, data): (mu, alpha, beta) = params …
Simd
  • 19,447
  • 42
  • 136
  • 271
34
votes
2 answers

python equivalent of qnorm, qf and qchi2 of R

I need the quantile of some distributions in python. In r it is possible to compute these values using the qf, qnorm and qchi2 functions. Is there any python equivalent of these R functions? I have been looking on scipy but I did non find anything.…
Donbeo
  • 17,067
  • 37
  • 114
  • 188
34
votes
3 answers

Fitting a 2D Gaussian function using scipy.optimize.curve_fit - ValueError and minpack.error

I intend to fit a 2D Gaussian function to images showing a laser beam to get its parameters like FWHM and position. So far I tried to understand how to define a 2D Gaussian function in Python and how to pass x and y variables to it. I've written a…
Kokomoking
  • 363
  • 1
  • 4
  • 5
34
votes
8 answers

Downsample array in Python

I have basic 2-D numpy arrays and I'd like to "downsample" them to a more coarse resolution. Is there a simple numpy or scipy module that can easily do this? I should also note that this array is being displayed geographically via Basemap modules.…
wuffwuff
  • 730
  • 2
  • 9
  • 19
34
votes
2 answers

Python double free error for huge datasets

I have a very simple script in Python, but for some reason I get the following error when running a large amount of data: *** glibc detected *** python: double free or corruption (out): 0x00002af5a00cc010 *** I am used to these errors coming up in…
Avneesh
  • 511
  • 1
  • 4
  • 13
34
votes
2 answers

Linear regression of arrays containing NANs in Python/Numpy

I have two arrays, say varx and vary. Both contain NaN values at various positions. However, I would like to do a linear regression on both to show how much the two arrays correlate. This was very helpful so far. However, using the following slope,…
HyperCube
  • 3,870
  • 9
  • 41
  • 53
34
votes
4 answers

Numpy transpose of 1D array not giving expected result

I am trying a very basic example in Python scipy module for transpose() method but it's not giving expected result. I am using Ipython with pylab mode. a = array([1,2,3] print a.shape >> (3,) b = a.transpose() print b.shape >> (3,) If I print the…
sarbjit
  • 3,786
  • 9
  • 38
  • 60
34
votes
8 answers

SciPy/Python install on Ubuntu

I'm currently following the tutorial Installing the SciPy Stack to install SciPy on Ubuntu 12.04 (Precise Pangolin) (I can't use apt-get install because I need a recent version). However, I get errors when I do the following commands: python…
msusplugas
  • 713
  • 3
  • 8
  • 16