Interpolate percentages - maintain sum of rows =1, maintain all values >0
8 views (last 30 days)
I would like to interpolate data that are percentages, that change at various points in time.
For each row (year) in the data, the sum of the columns must =100%
A B C D Sum
1990 10 40 40 10 100
1995 5 35 32 18 100
1998 0 32 44 24 100
2005 0 37 55 8 100
The data above is just an example.
I have been using interp1, but understand that there is no linkage between the columns
When I use linear interpolation, this works fine - all points are above 0, sum of each row = 100.
Using other methods:
- cubic - all points are above 0, but the rows do not sum 100.
- spline - some points go negative, but rows sum 100.
The problem is that the approximation oscillates around 0
What other interpolation method can I use (that isn't linear) where I can set conditions to prevent the approximation going below 0?
Matt J on 21 Apr 2013
Edited: Matt J on 21 Apr 2013
Raised cosine interpolation would be a possibility. For data xi spaced apart by 1, this would be
y(x)=sum_i y_i h(x-xi)
h(x)= 0.5*cos(x/pi)+0.5, abs(x)<=1
= 0, otherwise
but AFAIK there is no pre-packaged MATLAB function that offers it. You would have to code it from scratch. What's wrong with linear interpolation? What do you mean by "oscillates around zero"?