Tampilkan postingan dengan label Casio fx-CG50. Tampilkan semua postingan
Tampilkan postingan dengan label Casio fx-CG50. Tampilkan semua postingan

Casio fx-CG 50: Random Walk Histogram

Casio fx-CG 50:  Random Walk Histogram


Mosquitos an Inspiration, What? 


Inspiration:  

Ellenberg, Jordan.   Shape:  The Hidden Geometry of Information, Biology, Strategy, Democracy, and Everything Else  Penguin Books:  New York, NY. 2021


The beginning of Chapter 4, Sir Ronald Ross proposes the problem:  In a simple case, a mosquito can only travel in one of two directions, which is northeast or southwest.   The goal was to find the average distance a mosquito is from its home after a given life span.


The program TWALK would address a similar problem.  


N = number of trials


S = number of steps the mosquito (or whatever you want to imagine) walks in a single direction


Each trial calculates the final position.  The program draws a histogram of all the trails.   


TWALK gives two choices:


(-1, 1):  Each turn, the mosquito must move forward 1 step or backward 1 step


(-1, 0, 1):  Each turn, the mosquito must either move forward 1 step, move backward 1 step, or stay still for one turn. 



Drawing an Histogram Program in Casio Programming


Syntax:


S-Grph#  DrawOn, Hist, List x, 1, [ColorLinkOff], [Color] ColorLighter


# = Graph 1, 2, 3

List x = List 1 to List 26

Color Commands:  ColorLinkOff, 

Colors: One of 8 eight colors

ColorLighter: the fill of the color is lighter than the bar


The color commands are optional.  If you are using a Casio fx-9750GIII, leave of the color commands.



Casio fx-CG50 Program TWALK


Text:

'ProgramMode:RUN

"EWS 2022-08-04"

"RANDOM WALK 2.0"

"NO. TRIALS"?->N

N->Dim List 26

"NO. STEPS"?->S

Menu "STEPS","_(-)_1,1",2,"-1,0,1",3

Lbl 2:2->F:Goto 1

Lbl 3:3->F:Goto 1

Lbl 1

For 1->I To N

F=2=>Sum (2*RanInt#(0,1,S)-1)->List 26[I]

F=3=>Sum (RanInt#((-)1,1,S))->List 26[I]

Next

"POSITIONS LIST:"Disps

List 26Disps

(-)S->H Start

1->H pitch

S-Gph1 DrawOn,Hist,List 26,1,ColorLinkOff,Blue ColorLighter 

DrawStat



On the Screen:

"EWS 2022-08-04"

"RANDOM WALK 2.0"

"NO. TRIALS"?→N

N→Dim List 26

"NO. STEPS"?→S

Menu "STEPS","-1,1",2,"-1,0,1",3

Lbl 2:2→F:Goto 1

Lbl 3:3→F:Goto 1

Lbl 1

For 1->I To N

F=2⇒Sum (2×RanInt#(0,1,S)-1)→List 26[I]

F=3⇒Sum (RanInt#(-1,1,S))→List 26[I]

Next

"POSITIONS LIST:"◢

List 26◢

-S->H Start

1->H pitch

S-Gph1 DrawOn,Hist,List 26,1,ColorLinkOff,Blue ColorLighter 

DrawStat


Examples


N = 50, S = 5


(-1, 1):  Mosquito cannot rest





(-1, 0, 1): Mosquito can rest






Wishing you an excellent day,


Eddie 


All original content copyright, © 2011-2022.  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. 


Casio fx-CG 50 and fx-9750GIII: Regression Builder

Casio fx-CG 50 and fx-9750GIII:  Regression Builder


Introduction


The program LRBUILD lets the user fit bi-variate data (x,y) to a customized regression equation in the form:


y = C + Σ Cₙ * fₙ(x) 


where:


C = constant term.  This term is automatically calculated for by the program.


Cₙ = coefficient of each subsequent term of fₙ(x)


fₙ(x) = function, where the user can choose any of the following forms:


1.  x^A

2.  ln(A * x)

3.  e^(A * x)

4.  sin(A * x)


where A is a real number.  Angles are assumed to be in radian measure.  


For example, we can fit data by least squares method to this equation:


y = C + C_1 * x^2 + C_2 * e^(0.5 * x) + C_3 * sin(x)


You can add as many fₙ(x) terms as you like.


The program will give you the coefficients in a vertical matrix, starting from C and so forth, and the R^2 goodness of fit:


R^2 = 1 - SS_res / SS_tot


SS_res = Σ( y_observed - y_predicted)^2


SS_tot = Σ(y_observed - mean(y_oberserved))^2



Notes:


The characters _n (lower subscript n) and Σ (sigma symbol) are found on the CHAR (Character Select) on the programming editor menu (almost exit until the soft menu TOP, BOTTOM, SEARCH, ... displays).


The lines:


For 1 → I To 750

Next


are used to create a short pause.


There are two versions:  


Program files with the g3m extension is for the color Casio graphing calculators, such as the fx-CG50.   You can download this file here:

https://drive.google.com/file/d/1YidknrzjU_oRT3KLIzkEogbU_XFBCH0j/view?usp=sharing



Program files with the g1m extension is for the monochrome Casio graphing calculators, such as the fx-9750GIII (United States) and the fx-9860GIII (International).  You can download this file here:

https://drive.google.com/file/d/1GOO6VHGV_JRlNlbZB8ww3hK1qDqZaag_/view?usp=sharing



To transfer between Casio calculators, it is recommended to save them as text files.  Then transfer to the SAVE-F folder and load it on the home calculator.  Some editing may be necessary, such as <-1> with x^-1.


Casio fx-9750gIII and fx-CG50 (and probably most other Casio modern graphing calculators) Program: LRBUILD

(Extra spaces included for readability - this meant to be typed on the calculator)


Rad

ClrText

Locate 1,1,"LIN REG BUILDER"

Locate 1,2,"EWS 2022-01-17"

Locate 1,3,"Y=C+Σ(C_n×F_n(X))"   (n is the lower script n from the CHAR screen)

For 1 → I To 750

Next

"X DATA"? → List 1

"Y DATA"? → List 2

Dim List 1 → N

Dim List 1 → Dim List 3

{0} → List 4

{0} → List 5

Seq(1,X,1,N,1) → List 6

List→Mat(List 6) → Mat A

List→Mat(List 2) → Mat B

"CONSTANT TERM ADDED"

For 1 → I To 750

Next

Lbl 0

Menu "TERM?", "X^A", 1, "ln (AX)", 2, "e^(AX)", 3, "sin (AX)", 4, "CALCULATE", 5

Lbl 1

"A"? → A

Augment(List 4, {1}) → List 4

Got A

Lbl 2

"A"? → A

Augment(List 4, {2}) → List 4

ln(A×List 1) → List 6

Goto A

Lbl 3

"A"? → A

Augment(List 4, {3}) → List 4

e^(A×List 1) → List 6

Goto A

Lbl 4

"A"? → A

Augment(List 4, {4}) → List 4

sin(A×List 1) → List 6

Goto A

Lbl A

Augment(List 5, {A}) → List 5

List→Mat(List 6) → Mat D

Augment(Mat A, Mat D) → Mat A

Goto 0

Lbl 5

Dim List 4 → M

(Trn Mat A × Mat A)^-1 × Trn Mat A × Mat B → Mat C

"COEFFS:" ◢

Mat C ◢  

For 1 → I to N

0 → Y

For 1 → J To M

List 4[ J ] → L

List 5[ J ] → A

Mat C[ J, 1 ] → C

List 1[ I ] → X

L = 0 ⇒  Y + C → Y

L = 1 ⇒ Y + C × X^A → Y

L = 2 ⇒ Y + C × ln(AX) → Y

L = 3 ⇒ Y + C × e^(AX) → Y

L = 4 ⇒ Y + C × sin(AX) → Y

Next

Y = 0 ⇒ 1E-7    (lower case 10 on the fx-CG 50)

Y → List 3[ I ]

Next

1 - (Sum (List 2 - List 3)^2)÷(Sum (List 2 - Mean(List 2))^2) → R

"R^2="

R ◢

List→Mat(List 1, List 2, List 3) → Mat D



Variables:


List 1:  X Data

List 2:  Y Data

List 3:  Expected Y Data (Calculated)

List 4:  Operation Types:  0 - constant, 1 - x^a, 2 - ln(a*x), 3 - e^(a*x), 4 - sin(a*x)

List 5:  A


Mat A:  X data matrix 

Mat B:  Y data matrix

Mat C:  matrix of calculated coefficients



Examples


Example 1:

Fit the following data:


x data = {10, 25, 34, 46, 65}

y data = {39.7, 100, 135.9, 183.9, 260}


to the curve y = C + C1 * x + C2 / x


Remember the constant term is automatic.   

On the TERM? menu, select 

1.  X^A with A = 1

1.  X^A (again), this time with A = -1

5.  CALCULATE


Calculated coefficients:

[[ 0.1012904425 ]

[ 3.99874051 ]

[ -3.775351133 ]]


y = 0.012904425 + 3.99874051x - 3.775351133/x


R^2 = 0.9999994909


y' predicted data: 

{39.71116043, 99.91878916, 135.947281, 183.9612811, 259.9613413}


Example 2:

Fit the following data:


x data = {-0.35, -0.16, 0.27, 0.84}

y data = {-0.64, -0.31, 0.58, 2.06}


to the curve y = C + C1 * sin x  + C2 * e^x


Remember the constant term is automatic.   

On the TERM? menu, select 

4.  sin(A*X) with A = 1

3.  e^(A*X) with A = 1

5.  CALCULATE


Calculated coefficients:

[[ -0.9847711767 ]

[ 1.023495272 ]

[  0.9854914931 ]]


y = -0.9847711767 + 1.023495272 * sin x + 0.9854914931 * e^x


R^2 = 0.9999986129


y' predicted data:

{-0.6412613439, -0.3080521531, 0.5791860102, 2.060127487}


Example 3:

Fit the following data:


x data = {2, 3, 4, 5, 6}

y data = {22.5, 34, 45.5, 57.5, 69.75}


to the curve y = C + C1 * x^1.2 + C2 * ln(3*x)


Remember the constant term is automatic.   

On the TERM? menu, select 

1.  X^A with A = 1.2

2.  ln(A*X) with A = 3

5.  CALCULATE


Calculated coefficients:

[[ -0.08646217016 ] 

[ 6.83429695 ]

[ 3.855357541 ]]


y = -0.08646217016 + 6.83429695 * x^1.2 + 3.855357541 * ln(3* x)


R^2 = 0.9999924407


y' predicted data:

{22.52250254, 33.92570965, 45.56537698, 57.50145068, 69.73496014}


Eddie


All original content copyright, © 2011-2022.  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. 


Casio fx-9750GIIIl (and fx-CG 50): Ways to Solve Equations

An expert calculator user will be able to use the tools that the calculators has to offer.  Sometimes, the solutions may be found without the need of programming.


The calculator covered today is the Casio fx-9750GIII, which is named the Casio fx-9860GIII in countries outside of the United States.  I am very confident that the solving tools are available to most recent of Casio's graphing models, including the GII series, the first Prizm, and the current color graphing calculator fx-CG 50.


Solve vs SolveN


The functions Solve and SolveN are offered in the Run-Mat mode as well as a programming commands.  


Solve works with equations involving solving for X:


Solve( f(x) = g(x), guess for X)


If g(x) is omitted, then Solve uses f(x) = 0.  Numeric solutions are returned.



SolveN allows us to solve for any variable A-Z and Θ.   Instead of an initial guess, we can provide a lower and upper bound.  SolveN returns a list of solutions within the bound.  If the lower and upper bound are omitted, then the bounds are -9.999999999E99 and 9.999999999E99.


SolveN( left = right, variable, lower bound, upper bound)


If there is no right side given, then SolveN uses left = 0.   When possible, SolveN returns exact solutions:  fractions, square roots, and multiples of π.





Neither Solve or SolveN can return complex numbered answers.  





The Equation Mode


The Equation Mode allows for three type of solvers:


F1:  Simultaneous

F2:  Polynomial

F3:  Solver


On the fx-9750GIII, access the equation mode by pressing MENU, A.   The location of the Equation mode varies depending on the calculator.  


Simultaneous


Linear equations up to 6 x 6 systems can be solved.   Entries can be either real or complex, regardless of the Set Up.  The matrix is set up like this:


[   columns of coefficients (left)   |  (right) ]


For example:

a*x1 + b*x2 = s

c*x1 + d*x2 = t


shows:

1 2 3

1 [ a b s ]

2 [ c d t  ]


The current coefficients are stored in the variable matrix Sim Coef (S∙Cof), while the current solutions can be stored in the variable Sim Result (S∙Rlt).  These are read-only variables. Both variables can be found in the [VARS],[ F6 ] ( > ), [ F3 ] (EQUA) menu. 







Polynomial


The Casio graphing calculators can solve up to 6-degree polynomials.  Depending on the Set Up, the solutions can be restricted to real numbers or return complex numbered solutions.   However, none of the of coefficients in the polynomial to be solved can be complex numbers.


The current coefficients is stored in the variable matrix Poly Coef (P∙Cof), while the current solutions can be stored in the variable Poly Result (P∙Rlt).  These are read-only variables.   Both variables can be found in the [VARS],[ F6 ] ( > ), [ F3 ] (EQUA) menu. 







Solver


The solver will allow any equations with variables A-Z and Θ.  What is nice about this mode is that all the variables will be listed and you can select one variable to solve for.   Repeated scenarios can be explored without the need to recall the SolveN function.  






Those are some of the solving tools of the Casio graphing calculators.  Hopefully you find them useful.  


If there is an interest, I can explore ways to solve applications without the need for programming.


Eddie 


All original content copyright, © 2011-2022.  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. 


Backlink 9999 Traffic Super

Order Now...!!!!