Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

Regression Analysis - Constructing a model with constraints (Need help please)

Status
Not open for further replies.

Rgsherry

Electrical
Nov 27, 2013
15
0
0
DE
Hello,

I am trying to construct a general function/method based on two sets of minimum/maximum data point constraints, which can take on new values in different situations. The only known data for this general function is the starting point (y-axis intercept) and the x-range. The rate of change over time must equal zero, so the amount increased/decreased must be compensated within the x-range. Optimally will vary as little as possible, as long as it meets the constraints.

I attached a figure of an example plot. The minimum constraint data points are marked as the 'necessary' function. The maximum constraint data points are marked as 'maximal.' The function marked as 'case 2' is an example of the general function in question that would satisfy the constraints.

I would appreciate any advice or suggestions on how to approach this problem as I've had very little success so far. Thank you in advance.

so0qx1.jpg
 
Replies continue below

Recommended for you

Oh, my company's firewall blocks tinpic, sorry about that.

This seems like statistics problem, for which there is a better place to post this question: forum962 If you agree, you should red flag this posting and re-post in forum962



TTFN
faq731-376
7ofakss

Need help writing a question or understanding a reply? forum1529
 
Based on your constraints, wouldn't the optimal solution be (using the C language ternary "test?true:false" operator):

div=0
for i in x range
f(x) = min(x) > (f(0)-div) ? min(x) : max(x) < (f(0)-div) ? max(x) : f(0)-div
div += f(x)-f(0)
end for

?

I've assumed by "rate of change over time must equal zero" you mean the integral of the f(x) - f(0) must tend towards zero. If you really did mean the rate of change, then adjust accordingly.
 
That's correct liteyear, basically however much the function increases or decreases it must be compensated for within the x range. I must admit I have very little knowledge in C-language. I can see by the code it seems to take into account min and max points. So if these min and max functions each have a set of data points, this code would generate a function between them satisfying the constraints? Please excuse my inexperience with programming. I would really like to learn more about C-language and how I could use it to solve his problem.
 
Yes, the (untested) function generates a a set of points between the two constraint functions.

No need to worry about learning C at this stage. The ternary operator is simply this:

test ? a : b;

is equivalent to this psuedocode:

if (test)
a​
else
b​
end if

Just note that the b statement in my code is actually another test.
 
Status
Not open for further replies.
Back
Top