How to find the optimum intercept by fixing the gradient as a fit to experimental data?

1 回表示 (過去 30 日間)
HaAgain
HaAgain 2019 年 1 月 15 日
編集済み: Torsten 2019 年 1 月 16 日
I have a set of experimental data that share the relationship: y = A.x^n
I plot my data log y vs log x. The gradient is n and intercept is log(A) which I can obtain from the polyfit function.
I now want to fix the value of n and find the most optimum value of A by some kind of least squares algorithm with respect to the experimental data.
What is the best way to do this?
Thank you

採用された回答

Torsten
Torsten 2019 年 1 月 15 日
編集済み: Torsten 2019 年 1 月 15 日
Use polyfit to fit a polynomial of degree 0 against log(y) - n*log(x) and take exp() of the result.
This gives you optimal A for given n.
Solution is
A = exp( mean( log(y) - n*log(x) ) )
  2 件のコメント
HaAgain
HaAgain 2019 年 1 月 15 日
Yes! That makes a lot of sense based on analytical solution.
thank you
Torsten
Torsten 2019 年 1 月 15 日
編集済み: Torsten 2019 年 1 月 16 日
Or
A = sum(x.^n.*y)/sum(x.^(2*n))
for the original equation.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLinear and Nonlinear Regression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by