Search code examples
matlabcurve-fittingnonlinear-functions

non linear curve fitting with log functions


I have a set of data points pair (y,x). I want to fit a function using the form

y = c * x * log2(x)

I want to find the value of c. Matlab lsqcurvefit is not working for this. It seems to be stuck in local optima.

Any suggestions on how to do it?

Thanks!


Solution

  • As cdbitesky wrote, the simplest way to estimate c is to compute pointwise ratios and take the mean:

    c_est = mean(y ./ (x .* log2(x)));
    

    Another would be to use Matlab's matrix division, which performs a least squares fit:

    c_est = y / (x .* log2(x));
    

    The optimal way to estimate c can only be derived if you have an idea how (if at all) your data deviate from the ideal equation y = c * x * log2(x). Are your data corrupted by additive noise or multiplicative? Where does this noise come from? etc.