# Matlab Question - How to optimize parameters for two data sets [closed]

This is rather an easy problem but I cannot get my head around.

I have two curves in the form, say F(xi,fi) and G(xi,gi), with i = 1 to 65. F and G are supposed to be the same, but I get them unequal in raw format because each fi, gi contains additional leakage or bias.

My question is how to find coefficients that eliminate the bias.

I was doing following with no success. aF + bG = 0, or ai * fi + bi * gi = 0

subject to a constraint Sum[(ai-1)fi] = Sum[(bi-1)gi] = constant. Sum indicates summation over i's from 1 to 65.

I was, with some help, able to find coefficients algebraically.

a_i = g_i / 2 * sum_{j=1}^{j=65} (f_j - g_j) / sum_{j=1}^{j=65} (f_j * g_j)

b_i = -f_i / 2 * sum_{j=1}^{j=65} (f_j - g_j) / sum_{j=1}^{j=65} (f_j * g_j)

But it didn't give the correct shape, maybe because of not taking the constraint into account.

Any help would be much appreciated.

## closed as off-topic by fəˈnɛtɪk, Shaggy, Kirill L., Adám, AdmBorkBorkJan 8 at 13:39

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This site is for programming contests and challenges. General programming questions are off-topic here. You may be able to get help on Stack Overflow." – fəˈnɛtɪk, Shaggy, Kirill L., Adám, AdmBorkBork
If this question can be reworded to fit the rules in the help center, please edit the question.