interpolation

Interpolate / Extend quarterly to monthly series

一世执手 提交于 2019-11-30 06:03:46
问题 I have a data.frame that contains quarterly observations. I now want to interpolate monthly values (preferred cubic, linear is fine). The intermediate goal should be to create a data.frame with DATE as the index and missing values for all the monthly observations. Googling showed that I should create an empty data.frame for the whole time range and then merge it - but what ever I tried so far gave me errors. Here's my procedure; but since I'm a newb to r , I'm open to any suggestions for

Interpolation over an array (or two)

倾然丶 夕夏残阳落幕 提交于 2019-11-30 05:57:02
问题 I'm looking for a java library or some help to write my own interpolation function. That is I have two arrays of doubles which are potentially different sizes, but are ordered. I need to be able to make an estimate of intermediate values, and insert so that both arrays become the same size. In fact the total number of points appearing in the interpolation is the sum of the 2 array sizes minus 1. The range of each array must stay the same however, so there is no extrapolation needed. eg. a1 =

Cubic Spline Program

蹲街弑〆低调 提交于 2019-11-30 05:22:31
I'm trying to write a cubic spline interpolation program. I have written the program but, the graph is not coming out correctly. The spline uses natural boundary conditions(second dervative at start/end node are 0). The code is in Matlab and is shown below, clear all %Function to Interpolate k = 10; %Number of Support Nodes-1 xs(1) = -1; for j = 1:k xs(j+1) = -1 +2*j/k; %Support Nodes(Equidistant) end; fs = 1./(25.*xs.^2+1); %Support Ordinates x = [-0.99:2/(2*k):0.99]; %Places to Evaluate Function fx = 1./(25.*x.^2+1); %Function Evaluated at x %Cubic Spline Code(Coefficients to Calculate 2nd

ANTIALIAS vs BICUBIC in PIL(Python Image Library)?

╄→尐↘猪︶ㄣ 提交于 2019-11-30 05:19:05
问题 I am using PIL to resize my images, my case is to scale up the original image. I am confused about the algorithm used with `resample=ANTIALIAS'. According to the document below, ANTIALIAS seems to be the best while scaling down. I wonder In which case can BICUBIC win?(some of my test case shows bicubic is better choice) An optional resampling filter. This can be one of NEAREST (use nearest neighbour), BILINEAR (linear interpolation in a 2x2 environment), BICUBIC (cubic spline interpolation in

How to interpolate a line between two other lines in python

那年仲夏 提交于 2019-11-30 05:08:47
Note: I asked this question before but it was closed as a duplicate, however, I, along with several others believe it was unduely closed, I explain why in an edit in my original post . So I would like to re-ask this question here again. Does anyone know of a python library that can interpolate between two lines. For example, given the two solid lines below, I would like to produce the dashed line in the middle. In other words, I'd like to get the centreline. The input is a just two numpy arrays of coordinates with size N x 2 and M x 2 respectively. Furthermore, I'd like to know if someone has

Python pandas dataframe interpolate missing data

独自空忆成欢 提交于 2019-11-30 04:52:26
问题 I have a data set like the following. We only have data for the last day of a month I am trying to interpolate rest of it, is it the right way of doing it? Date Australia China 2011-01-01 NaN NaN 2011-01-02 NaN NaN - - - - - - 2011-01-31 4.75 5.81 2011-02-01 NaN NaN 2011-02-02 NaN NaN - - - - - - 2011-02-28 4.75 5.81 2011-03-01 NaN NaN 2011-03-02 NaN NaN - - - - - - 2011-03-31 4.75 6.06 2011-04-01 NaN NaN 2011-04-02 NaN NaN - - - - - - 2011-04-30 4.75 6.06 For interpolate this dataframe to

How do i fill “holes” in an image?

依然范特西╮ 提交于 2019-11-30 04:22:34
问题 I have photo images of galaxies. There are some unwanted data on these images (like stars or aeroplane streaks) that are masked out. I don't just want to fill the masked areas with some mean value, but to interpolate them according to surrounding data. How do i do that in python? We've tried various functions in SciPy.interpolate package: RectBivariateSpline, interp2d, splrep/splev, map_coordinates, but all of them seem to work in finding new pixels between existing pixels, we were unable to

Interpolating a scalar field in a 3D space

送分小仙女□ 提交于 2019-11-30 03:41:20
问题 I have a 3D space (x, y, z) with an additional parameter at each point (energy), giving 4 dimensions of data in total. I would like to find a set of x, y, z points which correspond to an iso-energy surface found by interpolating between the known points. The spacial mesh has constant spacing and surrounds the iso-energy surface entirely, however, it does not occupy a cubic space (the mesh occupies a roughly cylindrical space) Speed is not crucial, I can leave this number crunching for a while

Why doesn't Perl support interpolation of hashes in double quotes?

耗尽温柔 提交于 2019-11-30 03:28:22
问题 #!/usr/bin/perl use warnings; my %hash=("no1"=>1, "no2"=>2, ); print %hash; #Prints no11no22 print "%hash"; #Prints %hash Why doesn't Perl support interpolation of a hash within double quotes? It supports interpolation for scalars ($), arrays (@) then why not for hashes (%)? 回答1: How should a hash stringify? Scalars are obvious and arrays too. But what should a hash be? How useful will such a stringification be? Is it more or less useful than being able to use a % character unescaped in an

How to generate equispaced interpolating values

做~自己de王妃 提交于 2019-11-30 02:08:33
I have a list of (x,y) values that are not uniformly spaced. Here is the archive used in this question. I am able to interpolate between the values but what I get are not equispaced interpolating points. Here's what I do: x_data = [0.613,0.615,0.615,...] y_data = [5.919,5.349,5.413,...] # Interpolate values for x and y. t = np.linspace(0, 1, len(x_data)) t2 = np.linspace(0, 1, 100) # One-dimensional linear interpolation. x2 = np.interp(t2, t, x_data) y2 = np.interp(t2, t, y_data) # Plot x,y data. plt.scatter(x_data, y_data, marker='o', color='k', s=40, lw=0.) # Plot interpolated points. plt