Sunday, March 24, 2024

 

Casio fx-7000G vs Casio fx-CG 50: A Comparison of Generating Statistical Graphs



Today’s blog entry is a comparison of how a histogram, normal distribution graphs based on statistical data, scatter plots, and linear regression plot are generated on Casio’s first graphing calculator, the fx-7000G (1985) and the most recent (as of this blog post), the fx-CG 50 (2016). For the curious, the SD2 and LR2 modes are the statistical plot modes of the fx-7000G.


The procedures for the fx-7000G are the same for the fx-6500G, fx-7500G, fx-8000G (and equivalents) and fx-6300G.


The procedures for the fx-CG 50 are the same for the fx-CG 10/20, the fx-9860G series, and fx-9750G series.





Single Variable: Histogram Graphs and Normal Distribution Graphs


The screen shots for this section uses the example data:


Rank #

Rank (List 1)

Frequency (List 2)

1

10

11

2

20

19

3

30

36

4

40

39

5

50

33

6

60

13


Histogram: fx-7000G


1. Enter SD2 mode by pressing [ SHIFT ] [ MODE ] [ × ]. Execute Cls to clear the graph screen and Scl to clear the statistical data registers.

2. There is no automatic zoom adjustment for statistical data on the fx-7000G. Observe the data and set the range accordingly.

3. Count the number of ranks. We have to set aside additional memory registers for the bars. Do this by pressing [ SHIFT ] [ MODE ] [ . ] (Defm mode) and entering the number of ranks. For the data set above, we will need 6 additional registers (Defm 6).

4. Enter the data by using the [x^y] key, which acts as the data entry (DT) key for this mode. The format for each point is: rank ; frequency.

5. Draw the bar graphing by pressing [Graph] [ EXE ]. In other words, run the Graph Y= command without any other arguments. The bar graph can be traced.


(Note: The range I used is: Xmin: 10, Xmax: 70, Xscl: 10, Ymin: 0, Ymin: 40, Yscl: 10)





Normal Distribution Graph: fx-7000G


1. Clear the graph screen by executing Cls.

2. Redo the range. The y-values will have a probability of 1 or less. I like to set Ymin to a very small negative value so that the graph won’t be at the bottom of the screen.

3. Draw the normal graph by pressing [Graph] [SHIFT] [ ↑ ] {Line} 1 [ EXE ]. The command line is Graph Y=Line 1. The normal distribution curve can be traced.


Don’t forget to reset the memory to Defm 0 (or the setting you had) when you are done. Allocating for extra memory registers reduces the amount of program steps available.





Histogram: fx-CG 50


On the fx-CG 50, everything is done through the Statistics Mode. We can use any list from List 1 to List 26, generate multiple data sets and graphs, and on the fx-CG 10/20 and fx-CG 50, the graphs are in color.


1. For this graph, listed the ranks in List 1 and frequencies in List 2. From the main menu, press [ F1 ] {GRAPH}, [ F6 ] { SET }, and either [ F1 ], [ F2 ], or [ F3 ] to choose the graph slot Graph1, Graph2, or Graph3, respectively. Set the Graph Type to Hist.

2. Exit the setup by pressing [ EXIT ], and next press the corresponding graph slot. We will be prompted for the start value (Xmin) and the width (size of the rank). Press [ EXE ]. On the fx-CG 50, we do not have to worry about the window ranges because the Statistics mode automatically zooms the window to fit the data. Nice! The histogram can be traced.





Normal Distribution Graph: fx-CG 50


1. From the main menu, press [ F1 ] {GRAPH}, [ F6 ] { SET }. Change the Graph Type to N-Dist.

2. Exit the set up and press the graph slot. Again, the window zooms to fit the curve. The normal curve can be traced.




Linear Regression: Scatter Plot and Linear Regression Plot


X: (List 1)

Y: (List 2)

-8

-10

-4

-6

-1

0

2

3

5

6

8

8


Scatter Plot: fx-7000G


1. Enter LR2 mode by pressing [ SHIFT ] [ MODE ] [ ÷ ]. Execute Cls to clear the graph screen and Scl to clear the statistical data registers.

2. Adjust the Range (viewing window) to fit the data.

3. Enter the data by using the [x^y] key, which acts as the data entry (DT) key for this mode. The format for each point is: x, y.


If the point occurs more than once, use the format x, y; frequency.


The scatter plot dynamically updates and is shown each time a point is added.





Linear Regression Plot: fx-7000G


The line fits to the equation y = A + Bx (A is the y-intercept, B is the slope).


1. Execute the command Graph Y=Line 1 by pressing by pressing [Graph] [SHIFT] [ ↑ ] {Line} 1 [ EXE ]. The line is then plotted and can be traced. Easy as that.





Scatter Plot: fx-CG 50


Execute the statistics mode and enter the data. Like the histogram and normal distribution plots, the fx-CG 50 automatically adjusts the window to fit the statistical data for the scatter plot and linear regression line.


1. For this graph, List 1 has the x data and List 2 has the y data. From the main menu, press [ F1 ] {GRAPH}, [ F6 ] { SET }, and either [ F1 ], [ F2 ], or [ F3 ] to choose the graph slot Graph1, Graph2, or Graph3, respectively. Set the Graph Type to Scatter. You have an option of selecting the shape of the markers of the point.

2. Exit the setup by pressing [ EXIT ], and next press the corresponding graph slot. The scatter plot will be shown and you can trace the points.





Linear Regression Plot: fx-CG 50


1. While we are on the scatter plot screen, press [ F1 ] {CALC}, then [ F2 ] { X }. We have a choice of two forms: ax+b (default) or a+bx. I chose a+bx to match the fx-7000G.

2. The regression equation, along with the intercept, slope, and correlation are shown. When ready, press [ F6 ] {DRAW}.

3. The regression line is drawn, and the line can be traced.





I hope you enjoyed the comparisons between the classic fx-7000G and modern fx-CG 50.


Until next time,


Eddie


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

Saturday, March 23, 2024

Measuring a Distance with an Object in the Way

 Measuring a Distance with an Object in the Way




A Surveying Problem





Refer to the picture above. Here’s the situation: We are given a line and we are to determine a distance, X, from the Observer to the Survey Point. There is one problem though, there is a tree in the way, and the distance we are to measure goes directly through the tree.


Perhaps we can estimate the distance. Pick a point where the line of sight is not blocked. Let this new point be the Auxiliary Point and let C be the distance between the Observer and the Auxiliary Point.


We can also measure the distance between the Auxiliary Point and Survey Point, name this distance H. We can use the “right triangle” created to find the original distance X.



By the Pythagorean Theorem, we have:


X^2 + H^2 = C^2

X^2 = C^2 – H^2

X = √(C^2 – H^2) (only positive roots make geometric sense)


What if the calculator device does not have the square root function? Or if you are working by hand? In the 1938 book, The Principles and Practice of Surveying, Volume I (see the Source section), we can estimate the length of X without the need of taking a square root. Here is the derivation:


X^2 + H^2 = C^2

H^2 = C^2 – X^2

Observe that for any t, s: t^2 – s^2 = (t – s) × (t + s), and:


H^2 = (C – X) × (C + X)


If H is small, then C is close to X. Assume that H is small. As a result, C ≈ X. This derivation applies this approximation only to the term C + X:


H^2 ≈ (C – X) × (C + C)


Solve for X:


H^2 ≈ (C – X) × 2 × C

H^2 ÷ (2 × C) ≈ C – X

X ≈ C - H^2 ÷ (2 × C)


How good is the estimated formula?




Testing the Approximation


I used the HP 15C Collector’s Edition for testing the approximation formula. The code used to compare the approximate to the actual result:


Line #; Key Code; Key


Stack: y: hypotenuse (C), x: side length (H); (y > x)


01; 42, 21, 11; LBL A // approximate calculation

02; __, 44, _1; STO 1

03; __, __, 34; x<>y

04; __, 44, _2; STO 2

05; __, 45, _2; RCL 2

06; __, 45, _1; RCL 1

07; __, 43, 11; x^2

08; __, __, _2; 2

09; __, __, 10; ÷

10; __, 45, _2; RCL 2

11; __, __, 10; ÷

12; __, __, 30; -

13; __, 44, _3; STO 3

14; __, __, 31; R/S

15; __, 45, _2; RCL 2 // actual calculation

16; __, 43, 11; x^2

17; __, 45, _1; RCL 1

18; __, 43, 11; x^2

19; __, __, 30; -

20; __, __, 11; √

21; __, 44, _4; STO 4

22; __, __, 31; R/S

23; __, 45, _3; RCL 3 // absolute error

24; __, 45, _4; RCL 4

25; __, __, 30; -

26; __, 43, 16; ABS

27; __, 43, 32; RTN


(27 steps, 34 bytes)


Sample Data (rounded to 7 digits)


C

H

Approx.

Actual

Abs. Error

5

1

4.9

4.8989795

0.0010205

6

1

5.9166667

5.9160798

0.0005869

7

1

6.2985174

6.9282032

0.0003682

8

1

7.9375

7.9372539

0.0002461

9

1

8.9444444

8.9442719

0.0001725

10

1

9.95

9.9498744

0.0001256

5

2

4.6

4.5825757

0.0174243

6

2

5.6666667

5.6556842

0.0098124

7

2

6.7142857

6.7082039

0.0060818

8

2

7.75

7.7459667

0.0040333

9

2

8.7777778

8.7749644

0.0028134

10

2

9.8

9.7979590

0.0020410

5

3

4.1

4

0.1

6

3

5.25

5.1961524

0.0538476

7

3

6.3571429

6.3245553

0.0325875

8

3

7.4375

7.4161985

0.0213015

9

3

8.5

8.4852814

0.0147186

10

3

9.55

9.5393920

0.0106080

20

19

10.975

6.2449980

4.7300020

20

1

19.975

19.9749844

0.0000156

50

49

25.99

9.9498744

16.0401256

50

1

49.99

49.9899990

0.0000010




From the data above, it seems that the greater the difference between C and H, in general, the better the approximation.



Source


Breed, Charles B. and George L. Hosmer. The Principles and Practice of Surveying: Volume I. Elementary Surveying. 7th Edition. John Wiley & sons, Inc. London, Chapman & Hall, Limited. 1938. pg. 14


Eddie


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

Sunday, March 17, 2024

Casio fx-9750GIII and fx-CG 50: Playing Games with the Probability Simulation Mode

Casio fx-9750GIII and fx-CG 50: Playing Games with the Probability Simulation Mode






The Probability Simulation add-in has six types of probability simulations:

* Coin Toss

* Dice Roll

* Spinner

* Marble Grab

* Card Draw

* Random Numbers


The add-in application is available for the following calculators:

* Casio fx-9750GIII and fx-9860GIII (and Graph 75/85/95 series, Graph 35+ E II)

* Casio fx-CG 10/20 and fx-CG 50 (and Graph 90+E)

* Casio fx-9860G


I believe on the fx-9750GIII and fx-9860GIII, the Probability Simulation Add-In is available out of the box. For others, the add-in can be downloaded through Casio’s Worldwide Education Website: https://edu.casio.com/download/index.php.


Let’s look at three ways we can use the Probability Simulation add-in in games of chance. This is a great app when you don’t have a pair of dice, playing cards, or a bag of marbles around.


In the Set Up menu, there is an option for seed from 1 to 99999.


Screen shots are from the fx-CG 50.


Interaction with Other Modes


* Data can be stored into global lists 1-26. Lists in these Casio calculators contain only numerical information. Numerical codes are used for card suits and face cards.


* There are no commands from the Add-In that can be used in programming. The simulation is mean to be a stand-alone app.




Drawing a Poker Hand






From the main screen, press F5 for Card Draw. To simulate poker, go into set up by pressing [SHIFT] {SET UP}. We can set either a 52 playing card deck, which is the standard deck without Jokers, or a reduced deck of 32 cards (sevens through Aces only). We don’t want Replacement, so turn that off. Press [ EXIT ] to go back to the simulation.


To draw a single card, press [ F1 ]. To draw multiple cards, press [ F2 ] for { +n }. At the prompt, press [AC/ON] and enter the number of cards.


We will have to memorize the cards or note the down on paper or another writing device.


To save the cards drawn, select [ F3 ] (STORE). There are three lists:


Draw: Draw number

Value: Card value. 1 = Ace, 11 = Jack, 12 = Queen, 13 = King

Suit: 1 = Heart, 2 = Club, 3 = Spade, 4 = Diamond


Lists can be allocated to the global list variables List 1 to List 26. Press [ F6 ] { EXE } to store the cards. Storing results works similarly in other applications.



Rolling Dice in Adventure Games





In adventure and fantasy games such as Dungeon and Dragons, sometimes dice beyond the standard six-sided die is needed. The Dice Roll (F2 from the Main Menu) has dice that are four-sided, six-sided, eight-sided, twelve-sided, and twenty-sided. Up to three dice can be thrown at once.


A Simple Lottery





Random integers from 0 to 99 can be drawn with the Random Numbers. Again, the set up menu is the key. For the lottery, turn the Repeat option off. Above are four draws from a simple lottery from 63 numbers.



This has been a look at Casio’s Probability Simulation Add-In. Until next time,


Eddie


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


Saturday, March 16, 2024

DM42 and DM41X: Timing Programs

DM42 and DM41X: Timing Programs


How Long Does it Take?

There is a convenient way of timing programs on the Swiss Micros DM42 and DM41X. This is accomplished by the TIME function. The TIME function returns the time, initially shown in HH:MM:SS format. HH represents hours, MM represents minutes, and SS represents seconds. The time is stored internally in HH.MMSS format.

We will also use the HMS- function. The HMS- subtracts two time values in HH.MMSS format.

A format that time the performance of an algorithm:


TIME

STO ## (store in any variable desired)

...

[main code here]

TIME

RCL ## (recall time stored in the beginning)

HMS-

“TIME=” (shows the time using a message, optional)

ARCL ST X

AVIEW

RTN


The elapsed time is in HH.MMSS format.


One word of caution, I would not use this method if you plan to run the test and midnight (12:00 AM or 0:00 hours) comes in between execution.



Example Code


Here is an example program that measure long a loop takes. In the example, the loop requires to display the x and y values for the function:


y = 2/5 × ln((x + 1)^2 ÷ 5) for x = 0 to 25.



Swiss Micros DM41X Code


01 LBL ^T TIMETST

02 0.025

03 STO 00

04 TIME

05 STO 01

06 LBL 00

07 RCL 00

08 INT

09 ^T X=

10 ARCL X

11 AVIEW

12 PSE

13 XEQ 01

14 ^T Y=

15 ARCL X

16 AVIEW

17 PSE

18 ISG 00

19 GTO 00

20 TIME

21 RCL 01

22 HMS-

23 ^T TIME=

24 ARCL X

25 AVIEW

26 RTN

27 LBL 01

28 1

29 +

30 X↑2

31 5

32 /

33 LN

34 2

35 *

36 5

37 /

38 RTN


Swiss Micros DM42 Code


00 {75-byte Prgm}

01 LBL “TIMETST”

02 0.025

03 STO 00

04 TIME

05 STO 01

06 LBL 00

07 RCL 00

08 IP

09 “X=”

10 ARCL ST X

11 AVIEW

12 PSE

13 XEQ 01

14 “Y=”

15 ARCL ST X

16 AVIEW

17 PSE

18 ISG 00

19 GTO 00

20 TIME

21 RCL 01

22 HMS-

23 “TIME=”

24 ARCL ST X

25 AVIEW

26 RTN

27 LBL 01

28 1

29 +

30 X↑2

31 5

32 ÷

33 LN

34 2

35 ×

36 5

37 ÷

38 RTN



The results that I have:


DM41X (SN 00843): 0.0049 (49 seconds)

DM42 (SN 03911): 0.0053 (53 seconds)


For reference, here are the values (rounded to 4 digits):


X

Y

0

-0.6438

1

-0.0893

2

0.2351

3

0.4653

4

0.6438

5

0.7896

6

0.9130

7

1.0198

8

1.1140

9

1.1983

10

1.2745

11

1.3442

12

1.4082

13

1.4675

14

1.5227

15

1.5743

16

1.6228

17

1.6685

18

1.7118

19

1.7528

20

1.7918

21

1.8291

22

1.8646

23

1.8987

24

1.9313

25

1.9627



I hope you find this helpful. Take care and until next time,


Eddie

All original content copyright, © 2011-2024. 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-7000G vs Casio fx-CG 50: A Comparison of Generating Statistical Graphs Today’s blog entry is a comparison of how a hist...