For which value of the scalar "b" does the (yet unspecified) function, y = f(x,b), go perfectly through the measured values?

1 view (last 30 days)
Imagine we have some function, y = f(x,b), which produces a n-vector of model outputs using as input the n-vector "x" and scalar "b". We collect the following data (for example):
x= 0 1 5 y_obs= 2 5 6
For which value of the scalar "b" does the (yet unspecified) function, y = f(x,b), go perfectly through the measured values?
Any examples of a question like this?

Answers (1)

Eric
Eric on 9 Nov 2017
Edited: Eric on 9 Nov 2017
Here is an example:
f = @(x,b) x+b; % What you are asking is impossible without defining f.
x = [0 1 5];
y_obs = [2 5 6];
[best_b,MSE] = fminsearch(@(b) mean((y_obs-f(x,b)).^2), 0);
This will minimize the mean squared error (MSE) between the function and your observations by adjusting b. The MSE should be 0 if you expect it to go perfectly through the values. In my example, the MSE is not zero because I was too lazy to figure out a function that would work.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!