Curve Fitting of Type y=ab^x Pseudocode

Earlier in article Curve Fitting of Type y=abx Algorithm, we discussed complete algorithm for fitting this curve to sets of data points using least square method. In this article, we are going to develop pseudocode for fitting this type of curve so that it will be easy to implement using high level programming languages.

Pseudocode for Fitting Curve y = abx

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 + Xi
     sumX2 = sumX2 + Xi * Xi
     sumY = sumY + log(Yi)
     sumXY = sumXY + 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 and B to b:
   a = exp(A)
   b = exp(B)
   
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