Wednesday, August 30, 2017

TI-84 Plus CE: Fitting a Parametric Line

TI-84 Plus CE:  Fitting a Parametric Line

The program PARLIN attempts to fit a parametric line for a collection of points (x(t), y(t)) using the following equations:

x = a * t + b
y = c * t + d

where the independent variable is t.  The program also plots the estimated line and the scatter plot.  I decided to keep the correlation (r^2) separate, so we can tell how well the line fits both the x and y data. 

TI-84 Plus CE Program PARAM

Notes:

L1: list 1, [ 2nd ] [ 1 ]; L2: list 2, [ 2nd ] [ 2 ], etc.  X1T, Y1T are from the [ vars ], Y-VARS, Parametric submenu

[square] is from [2nd] [ y= ] (stat plot) , MARK submenu, option 1

Program:

Param
Input "T LIST: ",L1
Input "X LIST: ",L2
Input "Y LIST: ",L3
FnOff
PlotsOff
LinReg(ax+b) L1,L2
a→A:b→B:r²→E
"AT+B"→X1T
ClrHome
Disp "X = A*T + B"
Disp A
Disp B
Disp "CORR: "
Pause E
LinReg(ax+b) L1,L3
a→C:b→D:r²→F
"CT+D"→Y1T
ClrHome
Disp "Y = C*T + D"
Disp C
Disp D
Disp "CORR: "
Pause F
min(L1)-5→Tmin
max(L1)+5→Tmax
FnOn 1
PlotsOn 1
GraphColor(1,BLUE)
Plot1(Scatter,L2,L3, [square] ,ORANGE)
ZoomStat

(Obviously use the colors and makers you like.   If you are working with a monochrome TI-83/TI-84, ignore the color commands.)

You can also download the program here:


Example 1

Fit the data to a parametric line:

T
X
Y
1
2.3
-3.0
2
2.8
-2.6
3
3.2
-2.3
4
3.7
-1.9
5
4.2
-1.6

Results:  
x = 0.47*t + 1.83 (r^2 ≈ 0.998)
y = 0.35*t – 3.33 (r^2 ≈ 0.997)




Example 2

Fit the data to a parametric line:

T
X
Y
1
-1.0
1.000
2
1.0
1.250
4
5.3
1.746
8
13.6
2.825
16
30.1
4.275

Results:
x = 2.075268817 * t – 3.066666667 (r^2 ≈ 0.99997)
y = 0.2196827957* t + 0.857166667 (r^2 ≈ 0.99145)



Eddie


This blog is property of Edward Shore, 2017.

Friday, August 25, 2017

HP Prime: Shewhart X-Bar Chart (Quality Chart)

HP Prime:  Shewhart X-Bar Chart (Quality Chart)

Introduction and Calculation

The program XCHART generates five variables that describe the parameters of a Shewhart X-bar chart for quality control purposes.  Two limits, upper and lower, are determined, set 3 deviations from the mean, set the boundaries in which a process can vary and still allow the process to be in control.

The samples are arranged in a matrix.  Each row is a sample, with each column is a data point of those samples.  For example, a 15 x 10 matrix represents 15 samples of with the sample size of 10.

The five parameters calculated are:

MM:  Grand Mean.  The mean of all the sample means. 

Sample mean = Σx / n

RM:  Range Mean.  The mean of all ranges of all samples. 

Range = max(sample) – min(sample)

MD:  Mean Deviation.  The mean of all the standard deviation of all samples.

Sample Deviation = √( (Σx^2 – (Σx)^2/n) / (n – 1)

L, U:  Lower and Upper limit of the x-bar chart.  How it is calculated is dependent on the sample size (number of columns).

If the size ≤ 25, then:

U = MM + a2 * RM
L = MM – a2 * RM

Where a2 is a constant.  The values of a2 for sample sizes 2 – 25 can be found here:  http://onlinelibrary.wiley.com/doi/10.1002/9781119975328.app2/pdf

Some values (2 – 11):
Sample Size
a2
Sample Size
a2
2
1.880
7
0.419
3
1.023
8
0.373
4
0.729
9
0.337
5
0.577
10
0.308
6
0.483
11
0.285

HP Prime Program XCHART

EXPORT XCHART(mat)
BEGIN
// 2017-08-25 EWS
// Quality control
// {grand mean, range mean,
// std.dev mean, LCL, UCL}

// Grand mean
LOCAL MM:=mean(mean(TRN(mat)));

// Average range
LOCAL RM,C,R,I,L,cl;
// sample size: columns
C:=colDim(mat);
// number of samples
R:=rowDim(mat);

FOR I FROM 1 TO R DO
cl:=row(mat,I);
RM:=RM+(MAX(cl)-MIN(cl));
END;
RM:=RM/R;

// Average deviation
LOCAL MD:=mean(stddev(TRN(mat)));


// Estimate LCL,UCL

LOCAL U,L;
IF C≤25 THEN
// a2 list for sample size 2-25
LOCAL a;
LOCAL a2:={1.88,1.023,.729,
.577,.483,.419,.373,.337,.308,
.285,.266,.249,.235,.223,
.212,.203,.194,.187,.18,.173,
.167,.162,.157,.153};
a:=a2(C-1);
L:=MM-a*RM;
U:=MM+a*RM;
ELSE
// c4 (C>25)
LOCAL c4:=√(2/(C-1))*((C/2-1)!/
((C-1)/2-1)!);
U:=MM+3*MD/(c4*√C);
L:=MM-3*MD/(c4*√C);
END;
// Results
RETURN {MM,RM,MD,L,U};
END;

Example:

Data Process 6 samples of 6 data points each:

9.48
10.07
10.98
8.9
11.53
11.05
10.04
8.78
10.8
9.45
11.34
8.9
10.75
10.48
10.08
9.36
10.61
9.92
10.05
8.99
10.00
8.33
9.3
9.77
9.65
9.41
10.08
8.91
11.43
9.08
9.74
9.08
11.17
11.21
9.94
8.89

Since the sample size is not greater than 25, the range is used, with a2 = 0.483 (for the size of 6).

Results:
MM = 9.93194444444
RM = 2.19
MD = 0.785268047476
L = 8.87417444444  (lower limit)
U = 10.9897144444  (upper limit)

According to the results, the process needs further investigation.

Sources:

Aczel, Amir D. and Sounderpandian, Jayavel.  Complete Business Statistics McGraw-Hill Irwin: Boston. 2006.  ISBN 13: 978-0-07-286882-1

“6.3.2.  What Are Variables Control Charts?”  Engineering Statistics Handbook.  http://www.itl.nist.gov/div898/handbook/pmc/section3/pmc32.htm
Retrieved August 24, 2017

Six Sigma Improvement with Minitab  “Appendix 2: Factors for control charts” Published on line June 22, 2011.   http://onlinelibrary.wiley.com/doi/10.1002/9781119975328.app2/pdf   Retrieved August 24, 2017

Eddie


This blog is property of Edward Shore, 2017.

TI-84 Plus CE and HP Prime: Wilson Score (Video Games)

TI-84 Plus CE and HP Prime:  Wilson Score

Introduction

There are various ways to rank games: by the popularity of players or by the custom levels the players (like Little Big Planet and Super Mario Maker). A method to rank is to use the number of likes (or hearts) a player or level receives.   Another method is to use the percentage of likes to the number of plays (trials).    

Another way to rank is to use the Wilson score interval (Edwin Wilson).  The general Wilson interval formula is:

I = ( p0 + z^2/(2*n) ± z * √((p0 * (1 – p0)/n) + (z^2/(4*n^2)) )/( 1 + z^2/n )

Where:

n = number of trials or players
p0 = percentage of likes (successes) = likes/trials
z = z-score of the confidence interval (center of the normal curve)

Some values of z:

99% confidence:  2.575829303
97% confidence:  2.170090375
95% confidence:  1.959963986
90% confidence:  1.644853626

Matthew Lane, author of Power Up: Unlocking the Hidden Mathematics in Video Games, modifies the Wilson interval to calculate the score with 95% confidence, using the approximation of z ≈ 1.96, as

s = ( p0 + 1.96^2/(2*n) - 1.96 * √((p0 * (1 – p0)/n) + (1.96^2/(4*n^2)) )/( 1 + 1.96^2/n )

The score takes the number of likes and plays into account.  The program WILSON calculates the above score.

TI-84 Plus CE Program WILSON

Input "LIKES: ",L
Input "TRIALS: ",T
L/T→P
P+1.96^2/(2*T)→S
S-1.96√((P(1-P)/T)+1.96^2/(4*T^2))→S
S/(1+1.96^2/T)→S
Disp "SCORE: ",S

HP Prime Program WILSON

EXPORT WILSON(L,T)
BEGIN
// 2017-08-24 EWS
// L: likes,T: trials
// Percentage of likes
LOCAL P0:=L/T;
// Calculation (in parts)
LOCAL S:=P0+1.96^2/(2*T);
S:=S-1.96*√((P0*(1-P0)/T)
+1.96^2/(4*T^2));
S:=S/(1+1.96^2/T);
RETURN S;
END;

Example

Here is a comparison of ranking methods for five levels for a given custom level of the making game Super Mario Maker (https://supermariomakerbookmark.nintendo.net/?difficulty=normal
Retrieved August 25, 2017)

Level
Likes
Plays
% of Likes
Wilson Score
Castle Of Bomb Spin Jump Arts
1024
6169
0.1659912466
0.1569147894
Smb3 the mini game Cave 5
3468
20423
0.1698085492
0.1647212552
Stepping Stones 101
31
176
0.1761363636
0.1269508811
Squid Sisters & The Flooded Cave
90
518
0.1737451737
0.1435495995
Tower of challenges 2
244
1394
0.175035868
0.1559880745

Source: 
Lane, Matthew.  Power-Up:  Unlocking the Hidden Mathematics in Video Games Princeton University Press:  Princeton.  2017  ISBN 9780691161518

Eddie


This blog is property of Edward Shore, 2017.

TI-84 Plus CE and Casio fx-3650P: Factorial of n! and (n + 1/2)!

TI-84 Plus CE and Casio fx-3650P:  Factorial of n! and (n + 1/2)!

Factorial Formulas

The factorial for any non-negative integer n is computed by:

n! = n * (n-1) * (n-2) * … * 1
where 0! = 1

All scientific calculators with the factorial function will calculate the factorial of any positive integer up to 69 (253 for calculators with an upper limit of 10^499). 

When the factorial required for numbers in the form n/2 (example:  0.5, 1.5, 2.5, 3.5, and so on), the formula is:

(n/2)! = √π * ((n/2) * (n/2 – 1) * (n/2 – 2) * … * 1/2 )
‘where 1/2! = √π/2 ≈ 0.8862269255

When n is not an integer, we usually have to rely on the Gamma function using the relation Γ(n + 1) = n!.  This will not be covered in this post.


TI-84 Plus CE Program FACTHALF

The program FACTHALF accepts either n or n/2 as an input, where n is a non-zero integer.

"2017-08-24 EWS"
"NIST.GOV"
Disp "N! or (N/2)!"
Prompt X
If fPart(X/2)≠0.5
Then
X!→F
Else
X/2→F
Repeat X=­0.5
X-1→X
X*F→F
End
F*√(π)→F
End
Disp F

Casio fx-3650P Program for (n/2)!

The program assumes that you calculating (n/2)!.  Valid arguments are 0.5, 1.5, 2.5, etc.

(36 steps)
? → X: 1 → Y: Lbl 1: XY → Y : X -1 → X: X ≠ -.5 Goto 1:
Y √π → Y

Table of Some (n/2)! Values

0.5! = (1/2)! ≈ 0.886226925
1.5! = (3/2)! ≈ 1.329340388
2.5! = (5/2)! ≈ 3.32335097
3.5! = (7/2)! ≈ 11.6317284
4.5! = (9/2)! ≈ 52.34277778
5.5! = (11/2)! ≈ 287.8852778

Source:

“6.3.2.  What Are Variables Control Charts?”  Engineering Statistics Handbook.  http://www.itl.nist.gov/div898/handbook/pmc/section3/pmc32.htm
Retrieved August 24, 2017

Eddie


This blog is property of Edward Shore, 2017.

Saturday, August 19, 2017

Eclipse and HHC 2017

Eclipse

On August 21, 2017 there will be a solar eclipse.  Totality (where the moon completely covers the sun) will occur in the northern part of Earth, including some of the United States.  

If you can't get to an area where you can see the eclipse, I believe it is possible to watch it online.  

For more information, click here:
https://eclipse2017.nasa.gov/

HHC 2017

I am looking foward to the HHC 2017 (HP Handheld Conference) in Nashville in September.  I will be speaking on the HP 12C calculator, one of the stables of the HP calculators.

For more information, click here:
http://hhuc.us/2017/

Stay safe, stay sane, and I will probably speak with you by the end of August!

Eddie

Sunday, August 13, 2017

Casio fx-3650p and HP 21S: The Intersection Point of a Quadrilateral

Casio fx-3650p and HP 21S: The Intersection Point of a Quadrilateral

Introduction

This program calculates the coordinates of the center of quadrilateral.  For the derivation, please see this link:  http://edspi31415.blogspot.com/2017/08/geometry-intersection-point-of.html


Casio fx-3650P

See the diagram below. 



Due to the lack of variable available, 7, the program asks for A, B, C, and D twice.  Most of my programs asks for the inputs, then executes calculations.  This program asks for some inputs, does some calculations, then asks for more input, then executes calculations, including replacing variables to make room for further calculations. 

Program (91 steps):

? → A : ? → B : ? → C : ? → D :
(D – B) ÷ (C – A → X :
B – A X → Y :
? → A : ? → B : ? → C : ? → D :
(D – B) ÷ (C – A → C :
B – A C → D :
(D – Y) ÷ (X – C → X
D + C X → Y

HP 21S

See the diagram below.  Input the following points into R0 through R7.



Program (the code and steps should be the same for the HP 20S):

Step
Code
Key
01
61, 41, A
LBL A
02
33
(
03
22, 3
RCL 3
04
65
-
05
22, 1
RCL 1
06
34
)
07
45
÷
08
33
(
09
22, 2
RCL 2
10
65
-
11
22, 0
RCL 0
12
74
=
13
21, 8
RCL 8
14
55
*
15
22, 0
RCL 0
16
32
+/-
17
75
+
18
22, 1
RCL 1
19
74
=
20
21, 0
STO 9
21
33
(
22
22, 7
RCL 7
23
65
-
24
22, 5
RCL 5
25
34
)
26
45
÷
27
33
(
28
22, 6
RCL 6
29
65
-
30
22, 4
RCL 4
31
34
)
32
74
=
33
21, 6
STO 6
34
55
*
35
22, 4
RCL 4
36
32
+/-
37
75
+
38
22, 5
RCL 5
39
74
=
40
21, 7
STO 7
41
33
(
42
22, 7
RCL 7
43
65
-
44
22, 9
RCL 9
45
34
)
46
45
÷
47
33
(
48
22, 8
RCL 8
49
65
-
50
22, 6
RCL 6
51
74
=
52
21, 8
STO 8
53
26
R/S
54
55
*
55
22, 6
RCL 6
56
75
+
57
22, 7
RCL 7
58
74
=
59
21, 9
STO 9
60
61, 26
RTN


Variables – HP 21S: 

Register
Input
Output
R0
A1

R1
B1

R2
C1

R3
D1

R4
A2

R5
B2

R6
C2
C’
R7
D2
D’
R8

X
R9

Y

Example



From top-left hand corner clockwise:  (-1, 4), (4, 6), (5, -1), (0, 0)

Results:
X = 1.357142857
Y = 2.035714286

Eddie


This blog is property of Edward Shore, 2017.

TI 84 Plus CE: Consolidated Debts

TI 84 Plus CE: Consolidated Debts   Disclaimer: This blog is for informational and academic purposes only. Financial decisions are your ...