Linear interpolation on a numpy array
I have the following numpy array: # A B C Y my_arr = np.array([ [.20, .54, .26], # <0 [.22, .54, .24], # 1 [.19, .56, .25], # 2 [.19, .58, .23], # 3 [.17, .62, .21] ]) # 4+ if a user enters a y (example,...
I have the following numpy array: # A B C Y my_arr = np.array([ [.20, .54, .26], # <0 [.22, .54, .24], # 1 [.19, .56, .25], # 2 [.19, .58, .23], # 3 [.17, .62, .21] ]) # 4+ if a user enters a y (example,...
Hi I'd like to convert a file that's tab delimited and looks like this: Species Date Data 1 Dec 3 2 Jan 4 2 Dec 6 2 Dec 3 to a matrix like this (species is the row header): 1 2 Dec 3 9 Jan 4 I'm guessing the part of the solution is to create a dictionary with two keys and use defaultdict to...
I want to make some unittests for my app, and I need to compare two arrays. Since array.__eq__ returns a new array (so TestCase.assertEqual fails), what is the best way to assert for equality? Currently I'm using self.assertTrue((arr1 == arr2).all()) but I don't really like it :\ ...
if I have a series of subplots with one column and many rows, i.e.: plt.subplot(4, 1, 1) # first subplot plt.subplot(4, 1, 2) # second subplot # ... how can I adjust the height of the first N subplots? For example, if I have 4 subplots, each on its own row, I want all of them to have the same width but the first 3 subplots to be short...
Hi All: I'm weaving my c code in python to speed up the loop: from scipy import weave from numpy import * #1) create the array a=zeros((200,300,400),int) for i in range(200): for j in range(300): for k in range(400): a[i,j,k]=i*300*400+j*400+k #2) test on c code to access the array code=""" for(int i=0;i<20...
Is there an efficient way to know how many elements are in an iterator in Python, in general, without iterating through each and counting? thanks. ...
Hello! I am trying to do a fit to a given function using Scipy. Scipy.optimize.leastsq needs a vectorized function as one of the input parameters. This all works fine, but now I have a more complicated function which is not vectorized automatically by Scipy/Numpy. def f1(a, parameters): b, c = parameters result = scipy.integr...
Hi, I have a set of data and I want to compare which line describes it the best (polynomes of different orders, exponential or logarithmic). I use Python and Numpy and for polynomial fitting there is a function polyfit(). But I found no such functions for exponential and logarithmic fitting. Are there any? Or how to solve it otherwise...
Hi, I have a matrix which is fairly large (around 50K rows), and I want to print the correlation coefficient between each row in the matrix. I have written Python code like this: for i in xrange(rows): # rows are the number of rows in the matrix. for j in xrange(i, rows): r = scipy.stats.pearsonr(data[i,:], data[j,:]) ...
I feel like I should know this, but somehow I'm drawing a blank for the last 30 minutes... How would one go plotting a plane in matlab or scipy from a normal vector and a point? I keep wanting to use the symbolic math solver, but I don't have the license for it currently... :\ Sorry if this is really basic, my brain just isn't working ...
I use the latest version of numpy/scipy. The following script does not work: import numpy as np import matplotlib.pyplot as plt from scipy.fftpack import fft, fftshift, fftfreq hn= np.ones(10) hF = fft(hn,1024) shifted = fftshift(hF) It gives the following error message: Traceback (most recent call last): File "D:...
How does one convert a Z-score from the Z-distribution (standard normal distribution, Gaussian distribution) to a p-value? I have yet to find the magical function in Scipy's stats module to do this, but one must be there. ...
Hi, I wonder if there is a direct way to import the contents of a csv file into a record array, much in the way that R's read.table(), read.delim(), and read.csv() family imports data to R's data frame? Or is the best way to use csv.reader() and then apply something like numpy.core.records.fromrecords()? ...
(Couldn't upload the picture showing the integral as I'm a new user.) ...
Hi all, I've been trying to use scipy.interpolate.bisplrep() and scipy.interpolate.interp2d() to find interpolants for data on my (218x135) 2D spherical-polar grid. To these I pass 2D arrays, X and Y, of the Cartesian positions of my grid nodes. I keep getting errors like the following (for linear interp. with interp2d): "Warning: ...
I currently use Python for most of my programming, but I'm interested in learning Clojure. What libraries do I need to reproduce the functionality I have with scipy, numpy, and matplotlib? Is there anything like the Enthought distribution? ...
Hi, long-time R and Python user here. I use R for my daily data analysis and Python for tasks heavier on text processing and shell-scripting. I am working with increasingly large data sets, and these files are often in binary or text files when I get them. The type of things I do normally is to apply statistical/machine learning algorith...
Is it possible to calculate the number e with high precision (2000+ decimal places) with Python? (I was thinking with Numpy or SciPy) ...
I am running Snow Leapord 10.6 and trying to install the following python modules: 1) numpy 2) scipy 3) matplotlib I am running into problems because OSX contains two version of Python: 1) /Library/Python/ 2) /System/Library/Frameworks/Python.framework/ It appears that when I execute the following command: sudo easy_install -U {modu...
I have a 2d numpy.array, where the first column contains datetime.datetime objects, and the second column integers: A = array([[2002-03-14 19:57:38, 197], [2002-03-17 16:31:33, 237], [2002-03-17 16:47:18, 238], [2002-03-17 18:29:31, 239], [2002-03-17 20:10:11, 240], [2002-03-18 16:18:08, 252], [...