Showing posts with label normal distribution. Show all posts
Showing posts with label normal distribution. Show all posts

Saturday, July 5, 2025

HP 21S and TI-84 Plus CE: Normal Distributions and Hypothesis Tests

HP 21S and TI-84 Plus CE: Normal Distributions and Hypothesis Tests


Let’s compare how calculations involving the normal distribution are done between a classic calculator and a current one. The classic calculator is the rare HP 21S calculator from 1988 and the current calculator is the TI-84 Plus CE.


In 2017 (how time flies!) I wrote a review for the HP 21S (along with it’s cousin HP 20S):

https://edspi31415.blogspot.com/2017/04/retro-review-hewlett-packard-hp-20s-and.html.


Normal Distribution Calculations


z = z-score, point; p = probability, area


Assumptions: The mean is assumed to be 0 while the standard deviation is 1. (μ = 0, σ = 1).


Lower Tail (-∞, z)



HP 21S

TI-84 Plus CE*

Example

Given z, find p

Keystrokes:

1 [ - ] z [ ←| ] (Q(z)) [ = ]

normalcdf(-1E99, z)

Input: z = 0.77
Result:
p ≈ 0.7794

Given p, find z

Keystrokes:

[ ( ] 1 [ - ] p [ ) ] [ |→ ] (zp)

invNorm(p)

Input: p = 0.77
Result:
z ≈ 0.7388


* also includes TI-83 Plus, TI-84 Plus, TI-83 Premium (Python), TI-82 Advanced, and I do believe it is the same syntax for TI-89/Nspire family


Upper Tail (z, +∞)


HP 21S

TI-84 Plus CE*

Example

Given z, find p

Keystrokes:

z [ ←| ] (Q(z))

normalcdf(z, 1E99)

Input: z = 0.49
Result:

p ≈ 0.3121

Given p, find z

Keystrokes:

p [ |→ ] (zp)

InvNorm(1 - p)

Input: p = 0.49
Result:

z ≈ 0.0251


Two Tail (-z, z)


HP 21S**

TI-84 Plus CE*

Example

Given z, find p

Keystrokes:

z [ STO ] [ 0 ] [ +/- ]

[ ←| ] (Q(z)) [ - ]
[ RCL ] 0 [ ←| ] (Q(z)) [ = ]

normalcdf(-z, z)

Input: z = 1
Result:

p ≈ 0.6827

Given p, find z

Keystrokes:

p [ ÷ ] 2 [ = ] [ STO ] 0
Lower Limit:

[ ( ] 0.5 [ - ] [ RCL ] 0 [ ) ] [ |→ ] (zp)
Upper Limit:

[ ( ] 0.5 [ + ] [ RCL ] 0 [ ) ] [ |→ ] (zp)

InvNorm(p, 0, 1, CENTER)

Input: p = 0.25
Result:

Upper: z ≈ 0.3186

Lower: z ≈ -0.3186


** HP 21S: A memory register is needed for this particular algorithm. I use register 0 for this example.



Sample Test of the Mean: Is the Proposed Mean the True Mean? (μ0 = μ)


Perform a significant test of whether a proposed mean (μ0) is the true mean (μ) given data from a sample:


x-bar: arithmetic mean of a sample

σ: population deviation of the sample

n: sample size


In this test, the null or default hypothesis is μ =μ0, while the alternate hypothesis is μ ≠ μ0.


Your confidence level and critical level, α, are complimentary. For example, if you want a 95% confidence level, your critical level, or α, is: α = 1 – 0.95 = 0.05 (5%). This is a two-tail test.


HP 21S

TI-84 Plus CE

[ ←| ] [ ← ] (LOAD) (A) (1-Stat)
n [ XEQ ] D

μ [ R/S ]

σ [ R/S ]



Test Method # 1:

α [ ÷ ] 2 [ = ] [ |→ ] (zp) (= critical value)

μ0 [ XEQ ] B (= test value)


Null: μ0 = x-bar, Alternative: μ0 ≠ x-bar

If test value < critical value, do not reject null hypothesis

If test value > critical value, reject null hypothesis and accept the alternate hypothesis


Test Method # 2:

μ0 [ XEQ ] B [ ←| ] [ 1 ] (Q(z)) (= p)


Null: μ0 = x-bar, Alternative: μ0 ≠ x-bar

If p > α / 2, do not reject null hypothesis

If p < α / 2, reject null hypothesis and accept the alternate hypothesis


Note:

LBL D: store summary statistics for the test of one sample mean or probability. For this test, the standard error that is shown will not be used.


LBL B: calculate the z-score:

z = (x-bar – μ0) / (σ / √n)

[ stat ], TESTS, 1: Z-Test…

Inpt: Stats
(Input shown as Inpt)

μ0: enter μ0

σ: enter σ

x-bar: enter x-bar

n: enter n

Select μ ≠ μ0 (alternate hypothesis)

Select Calculate


Test Method # 1:

critical value: normalcdf(α/2, 1E99)

test value: [ vars ], 5: Statistics…, TEST, 2: z


Null: μ0 = μ, Alternative: μ0 ≠ μ

If test value < critical value, do not reject null hypothesis

If test value > critical value, reject null hypothesis and accept the alternate hypothesis


Test Method # 2:


Compare p to α


Null: μ0 = x-bar, Alternative: μ0 ≠ x-bar

If p > α, do not reject null hypothesis

If p < α, reject null hypothesis and accept the alternate hypothesis


One line command:

Z-Test(μ0, σ, x-bar, n, alt)

alt: -1 for μ0 < μ, 0 for μ0 ≠ μ, 1 for μ0 > μ


Example:

n = 515, μ = 7.65, σ = 3.56

α = 5% = 0.05, μ0 = 7.7, α / 2 = 0.025

[ ←| ] [ ← ] (LOAD) (A)
515 [ XEQ ] D

7.65 [ R/S ]

3.56 [ R/S ]


0.05 [ ÷ ] 2 [ = ] [ |→ ] (zp)

(critical value = 1.9600)

7.7 [ XEQ ] B

(z ≈ -0.3187 < 1.9600)


7.7 [ XEQ ] B [ ←| ] [ 1 ] (Q(z))

(p ≈ 0.6250 > 0.025)


Do not reject null hypothesis

Example:

n = 515, μ = 7.65, σ = 3.56

α = 5% = 0.05, μ0 = 7.7


[ stat ], TESTS, 1: Z-Test…

Inpt: Stats

μ0: 7.7

σ: 3.56

x-bar: 7.65

n: 515

Select μ ≠ μ0

Select Calculate


Results:

μ≠7.7

z=-0.3187304977

p=0.7499310153

x-bar=7.65

n=515



p ≈ 0.7499 > 0.05

z ≈ -0.3187 < 1.9600


Do not reject null hypothesis


This is one of several z-tests that can be performed.


Confidence Interval


Determine a confidence level of where the true mean is located given data from a sample:


x-bar: arithmetic mean of a sample

σ: population deviation of the sample

n: sample size


Confidence Mean:

x-bar ± (z * σ) / √n


z: absolute value of the z-score where the two tail probability equals c.

Using TI-84 Plus CE commands: invNorm(c, 0, 1, CENTER)


HP 21S

TI-84 Plus CE

[ ←| ] [ ← ] (LOAD) (A)
n [ XEQ ] D

μ [ R/S ]

σ [ R/S ]


Confidential Interval:

[ ( ] 1 [ - ] c [ ) ] [ ÷ ] 2 [ = ]

[ |→ ] [ 1 ] (zp)

[ XEQ ] C

→ precision [ R/S ]

→ lower limit [ R/S ]

→ upper limit


Note:

LBL C: Confidence interval

precision = (z * σ) / √n

lower limit = x-bar – precision

upper limit = x-bar + precision

[ stat ], TESTS, 7: Zinterval…


Inpt: Stats (Input is shown as Inpt)

σ: enter σ

x-bar: enter x-bar

n: enter n

C-Level: enter confidence level as a decimal

Calculate


One line command:

ZInterval σ, x-bar, n, c

n = 389, μ = 88.84, σ = 10.25

c = 90% = 0.9

[ ←| ] [ ← ] (LOAD) (A)
389 [ XEQ ] D

88.84 [ R/S ]

10.25 [ R/S ]

[ ( ] 1 [ - ] 0.9 [ ) ] [ ÷ ] 2 [ = ]

[ |→ ] [ 1 ] (zp)

[ XEQ ] C

→ 0.8548 [ R/S ]

→ 87.9852 [ R/S ]

→ 89.6948

n = 389, μ = 88.84, σ = 10.25

c = 90% = 0.9

Inpt: Stats

σ: 10.25

x-bar: 88.84

n: 389

C-Level: 0.9


Result:

(87.985, 89.695)

x-bar = 88.84

n = 389



Sources


CalcBlog “Hypothesis Testing using Z-Test on the TI-83 Plus, TI-84 Plus, TI-89, and Voyage 200” February 6, 2011. https://www.calcblog.com/hypothesis-testing-z-test-on-ti84-ti89-graphing-calculator/ Accessed January 30, 2025.


Hewlett Packard HP-21 Stat/Math Calculator: Owner’s Manual Edition 3. June 1990.


TI-Basic Developer “The Z-Test( Command” http://tibasicdev.wikidot.com/z-test Accessed January 30, 2025.

Enjoy! Until next time,


Eddie


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

Casio fx-3900Pv: Linear System, Poisson Kernel, Normal Distribution, 3 x 3 Matrix Determinant

Casio fx-3900Pv: Linear System, Poisson Kernel, Normal Distribution, 3 x 3 Matrix Determinant


Today, we feature four programs for the classic Casio fx-3900Pv calculator. The fx-3900Pv has 300 steps.


My review from 2023: https://edspi31415.blogspot.com/2023/05/retro-review-casio-fx-3900pv.html


One of the great features of the early “inexpensive” algebraic keystroke programmable calculators (1980s) is that the programs can be seen and edited.


The programs listed will require inputs to be stored in to the memory registers prior to running the program by using the [ Kin ] key.



Casio fx-3900Pv: 2 x 2 Systems


This program solves 2 x 2 linear systems. The Constant memory registers (K1 – K6) are mapped as follows:


K4 * x + K5 * y = K6

K1 * x + K2 * y = K3


The equations are solved as follows:

x = (K2 * K6 – K5 * K3) / M

y = (-K1 * K6 + K4 * K3) / M

where M = (K4 * K2 – K1 * K5)


This program takes 36 steps.


Code:

Kout 4 (determinant)

×

Kout 2

-

Kout 1

×

Kout 5

=

Min

HLT (Pause program, shows determinant. We want a nonzero-determinant.)


(

Kout 2

×

Kout 6

-

Kout 5

×

Kout 3

)

÷

MR

=

HLT (Solve for x)


(

Kout 1

+/-

×

Kout 6

+

Kout 4

×

Kout 3

)

÷

MR

= (Solve for y)


Examples


Example 1

x – y = 5

x + 3 * y = 9


Store the parameters: 1 Kin 4, -1 Kin 5, 5 Kin 6; 1 Kin 1, 3 Kin 2, 9 Kin 3

Results: det = 4, x = 6, y = 1


Example 2

3 * x + 16 * y = 49

5 * x – 2 * y = 22


Store the parameters: 3 Kin 4, 16 Kin 5, 49 Kin 6; 5 Kin 1, -2 Kin 2, 22 Kin 3

Results: det = -86, x = 5.23255814, y = 2.081395349



Casio fx-3900Pv: Poisson Kernel


The program calculates the kernel using the formula:


Pr(θ) = (1 – r^2) / (1 – 2 * r * cos θ + r^2),

0 ≤ r < 1, -π < θ ≤ π


This program takes 22 steps.


Store r in register 1, θ in register 2.


Code:

Rad (Mode 5)

(

1

-

Kout 1

x^2

)

÷

(

1

-

2

×

Kout 1

×

Kout 2

cos

+

Kout 1

x^2

)

=


Examples


Example 1:

r = 0.5, θ = 2.1

0.5 Kin 1, 2.1 Kin 2

Result: 0.4273879049


Example 2:

r = 0.268, θ = 0.842

0.268 Kin 1, 0.842 Kin 2

Result: 1.298397221


Source:

“Poisson Kernel” Wikipedia. May 28, 2024. https://en.wikipedia.org/wiki/Poisson_kernel

Retrieved November 26, 2024


Casio fx-3900Pv: Normal Distribution (Integration)


The program, which is ran in Integration Mode (Mode 1):


∫( e^(-t^2 / 2) / √(2 * π) dt, a, b)


To calculate, really approximate the integral:

MODE 1 P#

Store a level n (1-9), SHIFT RUN

Lower limit RUN

Upper limit RUN


The level n corresponds to the integration intervals 2^n. The higher n is, the longer the calculation takes but the accurate the integral is.


The integrated variable is stored in memory M. Start the function using Min.


Code:

Min

(

MR

x^2

+/-

÷

2

)

e^x

÷

(

2

×

π

)

=


Examples


The following examples will use n = 4.


Example 1: lower limit = 0, upper limit = 3. Result: 0.49865

(actual ≈ 0.4986501019)


Example 2: lower limit = -1, upper limit = 1. Result: 0.6827

(actual ≈ 0.6826894921)


Example 3: lower limit = -2, upper limit = 1.5. Result: 0.910443

(actual ≈ 0.910 4426667)



Casio fx-3900Pv: 3 x 3 Determinant


This program calculates the determinant of a 3 x 3 matrix. How are we to do this with only seven memory registers?


The program sets the matrix as:


[ [ 1st input, 2nd input, 3rd input ] [ K4, K5, K6 ], [ K1, K2, K3 ] ]


The user will be stop execution three times. At each time, enter the element corresponding to the top row.


For example:


[ [ 1, 2, 3 ] [ 4, 5, 6 ] [ 7, 8, 9 ] ]


Store 4 in K4, 5 in K5, 6 in K6; 7 in K1, 8 in K2, 9 in K3. While running, enter 1, 2, then 3 during program execution.


The determinant is stored to memory M. This program takes 40 steps.


Code:

(

Kout 5

×

Kout 3

-

Kout 2

×

Kout 6

)

×

ENT # (enter a legitimate number to continue, prompt for row 1, column 1)

=

Min


(

Kout 4

×

Kout 3

-

Kout 6

×

Kout 1

)

×

ENT # (prompt for row 1, column 2)

=

M-


(

Kout 4

×

Kout 2

-

Kout 5

×

Kout 1

)

×

ENT # (prompt for row 1, column 3)

=

M+


MR


Examples


Example 1:

[ [ 1, 5, 6 ] [ 2, 7, 8 ] [ 11, 4, 3 ] ]


Store:

(2nd row) 2 Kin 4, 7 Kin 5, 8 Kin 6

(3rd row) 11 Kin 1, 4 Kin 2, 3 Kin 3

Run the program (P1-P4): 1 RUN, 5 RUN, 6 RUN

Result: -15


Example 2:

[ [ -3, 0, 9 ] [ 0 , -3, 9 ] [ 9, -3, 0 ] ]


Store:

(2nd row) 0 Kin 4, -3 Kin 5, 9 Kin 6

(3rd row) 9 Kin 1, -3 Kin 2, 0 Kin 3

Run the program (P1-P4): -3 RUN, 0 RUN, 9 RUN

Result: 162


Until next time,


Eddie


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

HP 20S - Normal Distribution, Direction Cosine, Fire Friction Loss

HP 20S - Normal Distribution, Direction Cosine, Fire Friction Loss


HP 20S Normal Distribution


Goal: To estimate the area of the normal curve


∫( e^(-x^2 / 2) dx, a, b) / √(2 * π)


Steps:

1. Enter the programming editor: [ <| ] [ R/S ] {PRGM}

2. Load the integration program: [ <| ] [ ← ] {LOAD} [ e^x ] { B }. The screen shows “int”.

3. Go one up one step to get to Step 58: [ <| ] [ 8 ] { ↑ }

4. Enter the program after 58: 61, 41, F (LBL F)

51, 11

x^2

45

÷

2

2

74

=

32

±

12

e^x

45

÷

33

(

2

2

55

×

61, 22

π

34

)

11

74

=


5. Store the lower limit in register 5: a [ STO ] [ 5 ]

6. Store the upper limit in register 6: b [ STO ] [ 6 ]

7. Enter the number of intervals, it must be an even integer, and execute label A: n [ XEQ ] [ √ ] { A }


Example

At n = 20 intervals, estimate areas (ALL setting)

a = 0, b = 3; area ≈ 0.498649878

a = -3, b = 3; area ≈ 0.997293118

a = -1, b = 2; area ≈ 0.818595675



HP 20S: Direction Cosines


The direction cosines of 3D vector v = [x, y, z] are:


a = arccos(x / norm(v))

b = arccos(y / norm(v))

c = arccos(z / norm(v))

where norm(v) = √( x^2 + y^2 + z^2 )


The following program sets the angle mode to degrees, however, a change in the second step will allow the user to use radians or grads instead. The program uses the rectangular to polar conversion to obtain the norm.


Math note:

Find the magnitude of (√(x^2 + y^2), z).


magnitude

= √( [√(x^2 + y^2)]^2 + z^2 )

= √( x^2 + y^2 + z^2)

= norm(v)


Executing the →P command gives the angle first. Obtaining the magnitude requires a swap. ( [ <| ] [ INPUT ] {SWAP} ).


61, 41, b

LBL B

61, 23

DEG (61, 24 for RAD, 61, 25 for GRD)

22, 1

RCL 1

31

INPUT

22, 2

RCL 2

51, 21

→ P

51, 31

SWAP

31

INPUT

22, 3

RCL 3

51, 21

→ P

51, 31

SWAP

21, 4

STO 4

22, 1

RCL 1

41, C

XEQ C

26

R/S

22, 2

RCL 2

41, C

XEQ C

26

R/S

22, 3

RCL 3

41, C

XEQ C

61, 26

RTN

61, 41, C

LBL C (subroutine)

45

÷

22, 4

RCL 4

74

=

51, 24

ACOS

61, 26

RTN


Store x in register 1, y in register 2, and z in register 3. The angles are shown in order


Examples (FIX 4):


x = 4, y = 8, z = 5

Direction Cosines: a ≈ 67.0231°, b ≈ 38.6734°, c ≈ 60.7941°


x = -3, y = 8, z = 6

Direction Cosines: a ≈ 106.6992°, b ≈ 39.9807°, c ≈ 54.9217°


Source:

“Direction Cosine” Wikipedia. Accessed November 5, 2024. https://en.wikipedia.org/wiki/Direction_cosine




HP 20S: Determining the Coefficient for Friction Loss


When fighting fires, the friction loss of a hose lay can be determined by the formula:


FL = C * (flow rate/100)^2 * (hose length/100)


where:


C = coefficient

flow rate = the rate of water in GPM (gallons per minute)

hose length = length of the hose in ft (feet)

FL = friction loss in PSI (pounds per square inch)


This formula assumes a single line is used.


Solving for C:


C = FL / ((flow rate/100)^2 * (hose length/100))


The friction loss was determined by using various flow rates and hose lengths by using the FireCalc Pocket Calculator. You can see my spotlight on the FireCalc Pocket Calculator here: https://edspi31415.blogspot.com/2024/11/spotlight-akron-brass-firecalc-pocket.html


Friction Loss Table:


1” Hose Size


GPM ↓ / Length →

100 ft

150 ft

200 ft

100

150

225

300

150

338

506

675

200

600

900

1200


1.5” Hose Size


GPM ↓ / Length →

100 ft

150 ft

200 ft

100

24

36

48

150

54

81

108

200

96

144

192


2” Hose Size


GPM ↓ / Length →

100 ft

150 ft

200 ft

100

8

12

16

150

18

27

36

200

32

48

64


The coefficient is built in to the FireCalc. I used the HP 20S to extract the coefficient by the following program:


61, 41, A

LBL A

33

(

22, 2

RCL 2

45

÷

1

1

0

0

0

0

34

)

51, 11

x^2

55

×

33

(

22, 3

RCL 3

45

÷

1

1

0

0

0

0

34

)

74

‘=

15

1/x

55

×

22, 1

RCL 1

74

=

61, 26

RTN



Values are stored in the following registers:

Register 1 = friction loss (PSI)

Register 2 = flow rate (GPM)

Register 3 = hose length (ft)


Fortunately, running the program with various data points above, I obtain the coefficient as:


1” Hose Size: coefficient = 150

1.5” Hose Size: coefficient = 24

2” Hose Size: coefficient = 8



Source:

Task Force Tips. “Hydraulic Calculations Every Firefighting Needs to Know” Firefighter Trending Report. 2024. Retrieved November 10, 2024. https://tft.com/hydraulic-calculations-every-firefighter-needs-to-know/


Enjoy!


Eddie


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

RPN: DM32 and DM42: Stopping Sight Distance (Metric)

RPN: DM32 and DM42: Stopping Sight Distance (Metric) The Stopping Sight Distance Formula – Derivation The stopping sight di...