# estimating curve given area constraints

• May 8th 2013, 06:16 PM
Tabby
estimating curve given area constraints
Hi all,

I am really looking for a solution, but I can really use a nudge in the right direction.

See my nice drawing below....

Attachment 28298

The curve with a blue / light green area below it represents a costumers electricity supplied by the gird and the green / light green represents a solar costumers total solar generation. The problem is the meter does not record negative values, so we can only guess what portion of the total generation went back to the grid when the demand hits zero. When demand from the grid is greater than zero their total demand is just the sum of the two numbers, but when the demand hits zero this becomes an over estimate, since a portion of that total generation is negative.

I need to estimate the dotted curve below zero when a costumers solar generation exceeds their demand. With that information I can then estimate what their demand would have been without solar.

Let X represent energy from the gird
Let S represent total solar generation

I have the total energy consumption from the grid when X > 0 and total solar generation. My though it is to interpolate the two points using a polynomial in a way that maintains the area of the total generation.

Are there methods for a "constrained" interpolation or are there better methods?

I was also thinking I might need to look at this as a system of equations rather than connecting two points. I kind of see it as a predator prey relationship, but I doubt that model applies.
• May 9th 2013, 04:03 PM
jpritch422
Re: estimating curve given area constraints
This doesn't sound very scientific since there is really no way to no for sure what that curve looks like below the horizontal line (at 0). What you might try is where the curve hits that horizontal line, try to get reasonably close to the tangent line of the curve at that point. Do that at both points where the curve hits 0. Let the two tangent lines intersect each other below the 0-line. That should give you a "ballpark" idea as to how much is negative. That would also give you a worst-case scenario. I hope this has helped a little bit.
Also a question: that dotted line that goes from one peak to the other. What does that represent?
• May 11th 2013, 11:34 AM
Tabby
Re: estimating curve given area constraints
I appreciate your input. I know there isn't much science behind all this, but that's business for you.

I like your idea as an overestimate, which is probably more meaningful than an underestimate. The curves are typically far from smooth, so estimating the first derivative at those points is hard. As a result, I interpolated the data with cubic splines and computed the derivatives using the splines at those endpoints. This gave me the two tangent lines and their intersection. The areas created by these triangles seem reasonable. Now I would like fit a smooth curve between these points that attains a minimum at the tangent intersection, but these three points are not equally spaced, so I am getting weird results.

I set up the following system:

a + b*x0 + c*x0^2 + d*x0^3 = y0
a + b*x_min + c*x_min^2 + d*x_min^3 = y_min
a + b*x1 + c*x1^2 + d*x1^3 = y1
b + 2*c*x_min + 3*d*x_min^2 = 0

where x0 is the first point where the curve hits zero, x_min is the intersection of the tangent lines, and x1 is where the curve crosses zero again and remains positive thereafter. With the third equations I'm trying to ensure the intersection y_min is the min. I was trying to fit another spline, but with unequal intervals, I ended up getting weird results.

Note: The dotted line on top is the sum of solar generation and grid consumption. I need to estimate the net generation (i.e., account for the negative portion) to make that dotted line representative of the costumers true consumption. If I just added the total generation I would be adding in energy they didn't use in their home.

Thanks