Sunday, March 12, 2023

Casio fx-CG50: Logistic Equation - Solving For Parameters From Two Data Points

Casio fx-CG50:  Logistic Equation - Solving For Parameters From Two Data Points



The Challenge



It can be a challenge, especially without a statistics software package or method like the maximum likelihood estimate, to fit data (x, p), to the curve:


p(x) = 1 / ( 1 + α * x^β ) = ( 1 + α * x^β )^-1



What happens if we just have two data points (x1, p1) and (x2, p2).  Then finding α and β turns into simpler task.   Either we find a quick estimate to extend to other data points or if we just have two data points, exact solutions.




Finding α and β



With the points (x1, p1) and (x2, p2), the system to solve is:


1 / ( 1 + α * x1^β ) = p1

1 / ( 1 + α * x2^β ) = p2


1 + α * x1^β = 1/p1

1 + α * x2^β = 1/p2


α * x1^β = 1/p1 - 1

α * x2^β = 1/p2 - 1 


Assuming that α ≠ 0, divide both equations to get:


x1^β / x2^β = (1/p1 - 1) / (1/p2 - 1)


Solve for β:


(x1/x2)^β = (1/p1 - 1) / (1/p2 - 1)


ln [ (x1/x2)^β  ] = ln [ (1/p1 - 1) / (1/p2 - 1) ]


β * ln [ (x1/x2) ] = ln [ (1/p1 - 1) / (1/p2 - 1) ]


β = ln [ (1/p1 - 1) / (1/p2 - 1) ] / ln [ (x1/x2) ] 


Then we can get α:  


α = (1/p1 - 1) / (x1^β) = (1/p2 - 1) / (x2^β) 




Casio fx-CG50 Program:  BETPARAM

(276 bytes)


The characters α and β are found in the CHAR sub menu (outside of the PRGM menu).  If you have a monochrome calculator or just don't want color, ignore the color commands.


The program then graphs the resulting equation.   The variables Y1 and Y2 (with the bold Y) represent functions of X.  

 


Red "P(X)=1÷(1+αX^β)"

"SOLVE FOR α, β"◢

Rad

"POINT 1"

"X1"?→Y

"P1"?→Q

"POINT 2"

"X2"?→Z

"Y2"?→R

ln ((Q^-1 -1)÷(R^1 - 1))

Ans÷ln (Y÷Z)→B

(Q^-1 - 1)÷(Y^B)→A

ClrText

Blue Locate 1,3,"EST. PARAMETERS"

Locate 1,4,"α="

Locate 5,4,A

Locate 1,5,"β="

Locate 5,5,B

"1÷(1+A×X^B)"→Y1

""→Y2

SetG-Color Green,1

DrawGraph

ZoomAuto



Examples


Example 1:

(x1, p1) = (0.5, 0.76)

(x2, p2) = (1.5, 0.70)





Example 2:

(x1, p1) = (3/2, 5/8)

(x2, p2) = (2/3, 3/8)






Source:


Sumpter, David.  The Ten Equations That Rule the World: And How You Can use Them Too.  Flatiron Books: New York.  2021.  ISBN 978-1-250-24696-7



Eddie



All original content copyright, © 2011-2023.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.