Curve Fitting of Type y=ax^b Pseudocode

In our previous article Curve Fitting of Type y=axb Algorithm, we discussed complete procedure for fitting this curve to sets of data points. In this article, we are going to develop pseudocode for fitting this curve so that it will be easy to implement using high level programming language like C, C++, Python, Matlab etc.

Curve Fitting of Type y=axb Pseudocode

1. Start

2. Read Number of Data (n)

3. For i=1 to n:
     Read Xi and Yi
   Next i

4. Initialize:
     sumX = 0
     sumX2 = 0
     sumY = 0
     sumXY = 0

5. Calculate Required Sum
   For i=1 to n:
     sumX = sumX + log(Xi)
     sumX2 = sumX2 + log(Xi) * log(Xi)
     sumY = sumY + log(Yi)
     sumXY = sumXY + log(Xi) * log(Yi)
   Next i

6. Calculate Required Constant A and b of Y = A + bX:
   b = (n * sumXY - sumX * sumY)/(n*sumX2 - sumX * sumX)
   A = (sumY - b*sumX)/n

7. Transformation of A to a:
   a = exp(A)
   
8. Display value of a and b

8. Stop

Recommended Readings

  1. Algorithm for fitting Curve y = axb
  2. Pseudocode for fitting y = axb
  3. C Program for fitting curve y = axb
  4. C++ Program for fitting curve y = axb
  5. Algorithm for fitting Curve y = abx
  6. Pseudocode for fitting y = abx
  7. C Program for fitting curve y = abx
  8. C++ Program for fitting curve y = abx