From: Carl on
I have monthly data (say monthly average temperature as it is something easy to understand and the math is the same), and I wish to create a forecast at daily resolution and the obvious way of doing so is using cubic splines.

However the normal spline function has the constraint that the spine curve passes through the input points specified,
ie) Si(Xi)=Yi
where Si is the i'th cubic spline
Xi is the i'th month (some date within it)
Yi is the temperature at Xi

The issue is I don't know the temperature on any one particular day instead I know the average for all days within that month so I would like to replace these constraints with:

The integeral of Si between (Xi and Xi+1) ./ (Xi+1 - Xi) =Yi

or alternatively

the mean of the xx values where Xi<= xx < Xi+1 = Yi

Then Xi could be the start of each month (an extra value would be required as the day after the last day of the last month to signify the end of the integral of the last spline.

Does such a function exist in Matlab, I currently do not have the spline toolbox so a solution that doesn't use it would be preferred.
From: John D'Errico on
"Carl " <carl.meade(a)scottish-southern.co.uk> wrote in message <i2s834$7sl$1(a)fred.mathworks.com>...
> I have monthly data (say monthly average temperature as it is something easy to understand and the math is the same), and I wish to create a forecast at daily resolution and the obvious way of doing so is using cubic splines.
>
> However the normal spline function has the constraint that the spine curve passes through the input points specified,
> ie) Si(Xi)=Yi
> where Si is the i'th cubic spline
> Xi is the i'th month (some date within it)
> Yi is the temperature at Xi
>
> The issue is I don't know the temperature on any one particular day instead I know the average for all days within that month so I would like to replace these constraints with:
>
> The integeral of Si between (Xi and Xi+1) ./ (Xi+1 - Xi) =Yi
>
> or alternatively
>
> the mean of the xx values where Xi<= xx < Xi+1 = Yi
>
> Then Xi could be the start of each month (an extra value would be required as the day after the last day of the last month to signify the end of the integral of the last spline.
>
> Does such a function exist in Matlab, I currently do not have the spline toolbox so a solution that doesn't use it would be preferred.

No function is publicly available that I know of.

As it turns out, I did write a code that does solve
exactly this problem though, but I don't have time
to post it on the FEX, since I would then need to
spend some time cleaning it up, carefully testing
it, etc.

Send me an e-mail, and I'll respond with the code
as it is. (Fully documented, and apparently working
from a simple test.)

John
From: Matt J on
"Carl " <carl.meade(a)scottish-southern.co.uk> wrote in message <i2s834$7sl$1(a)fred.mathworks.com>...
> I have monthly data (say monthly average temperature as it is something easy to understand and the math is the same), and I wish to create a forecast at daily resolution and the obvious way of doing so is using cubic splines.
============

You could set this up as matrix-vector equation using

http://www.mathworks.com/matlabcentral/fileexchange/26292-regular-control-point-interpolation-matrix-with-boundary-conditions

In there, you'll find Example1D.m showing how to set up matrix equations for general cubic B-spline interpolation. The modification for the problem you describe would be small.

Of course, it's not clear to me whether that matrix equation would be non-singular...