MATLAB: A simple question about linear regression

polyfitpolyvalregression

Hi, I have a n*2 matrix named Y which has two columns; the first column is my observation values and the second column is the probability associated with the observation value in the same row of the first column. Now If I have a set of probabilities let's call it Z(n*1) how can I fined a value for each probability with linear regression of Y values?

Best Answer

Try this (untested)
% Find regression formula:
value = Y(:, 1); % Value
p = Y(:, 2); % Probability
coefficients = polyfit(value, p, 3); % Fit 2rd order polynomial
% Now get estimate for some values Z
% Z is a n by 1 array of a bunch of values.
estimated_p = polyval(coefficients, Z)
If you want interpolation instead of regression, you can use interp1(). Just say what you want.
Related Question