Which will handle more interestingly shaped surfaces and the function only needs to be created once. The last time I checked (a version of scipy from 2007-ish) it only worked for monotonically increasing arrays of x and y)įor small arrays like this 4x4 array, I think you want to use this: Return interpolate.interp1d(cars, interpolate.interp1d(prices, a)(price))(car) # the most efficient since it creates the interpolationĭata = numpy.arange(0., 16.).reshape((4,4)) #2D array Here are some examples: # this follows your pseudocode most closely, but it is *not* Or simply write your own and not bother with scipy. Use scipy's interpolate.interp1d if both 1D arrays are monotonically increasing, or interpolate.bsplrep (bivariate spline representation) if not and your example arrays are as small as your example. First, store the a.p array as a 2D numpy array and then both the $4k-10k and 1-4 arrays as 1D numpy arrays. If you want the most computationally efficient solution I can think of and are not restricted to the standard library, then I would recommend scipy/numpy.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |