Tampilkan postingan dengan label TI-84 Plus CE. Tampilkan semua postingan
Tampilkan postingan dengan label TI-84 Plus CE. Tampilkan semua postingan

HP 71B and TI-84 Plus CE: Binary Decimal Conversions Revised

HP 71B and TI-84 Plus CE:  Binary Decimal Conversions Revised


The programs presented can easily convert integers without the needs of lists or strings in input.  



HP 71B Programs:  BINDEC, DECBIN


No modules are required.


BINDEC (137 bytes)


100 DISP "BIN>DEC" @ WAIT .5

105 DESTROY A,B,C,D,E

110 INPUT "BIN? ";A

115 B=1 @ D=0 @ C=A

200 E=A/10 @ A=INT(E)

205 D=D+10*B*(E-A) @ B=2*B

210 IF A THEN 200

300 DISP "(2)";C;"="D


DECBIN (130 bytes)


100 DISP "DEC>BIN" @ WAIT .5

105 DESTROY A,B,C,D

110 INPUT "DEC? ";D

115 B=0 @ A=D @ C=1

200 E=D/2 @ D=INT(E)

205 B=B+C*(D<E)

210 C=C*10

215 IF D THEN 200

300 PRINT A;"=(2)";B



TI-84 Plus CE Programs:  BINDEC2, DECBIN2



BINDEC2


"V.2"

Disp "BIN>DEC"

Input "BIN? ",A

1→B:0→D:A→C

Lbl 2

A/10→E:iPart(E)→A

D+10*B*(E-A)→D

2*B→B

If A:Goto 2

Disp "(2) "+toString(C)+"= "+toString(D)



DECBIN2


"V.2"

Disp "DEC>BIN"

Input "DEC? ",D

0→B:D→A:1→C

Lbl 2

D/2→E:iPart(E)→D

B+C*(D<E)→B

10*C→C

If D:Goto 2

Disp toString(A)+"=(2) "+toString(B)


This is recommended for only integer values of 512 (decimal base) or less.  


Example


Decimal: 476  (DEC>BIN)

Result Binary:  111011100


Binary:  10111011 (BIN>DEC)

Result Decimal:  187



Source


Craig, John Clark.  119 Practical Programs For The TRS-80 Pocket Computer  TAB Books Inc.  Blue Ridge Summit, PA.  1982 pg. 133



Happy computing,

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. 


HP 71B, TI 84 Plus CE: Egyptian Fractions to Unit Fractions by the Greedy Algorithm

HP 71B, TI 84 Plus CE:  Egyptian Fractions to Unit Fractions by the Greedy Algorithm


Introduction 


An Egyptian fraction consists of a sum of unit fractions.  A unit fraction is a fraction with 1 in its numerator and a positive integer in its denominator.   


Yesterday, we calculated the Egyptian fraction given unit fractions, full simplified.   Today, we will attempt the reverse process, breaking down an Egyptian fraction into a sum of unit fractions.


N/D = 1/A1 + 1/A2 + 1/A3 + 1/A4 + ....


The Algorithm


The Greedy Algorithm is used.  


The Greedy Algorithm attempts to start the expansion by using the division of ceiling(D/N) = int(D/N) + 1.   Please be aware that this may not be the fastest or more efficient way.  


We also have the problem of a lot of calculators inability to display long integers, that is longer than 10 (usually) before switching to scientific notation mode.  In order to accommodate for memory and the calculator's ability to display integers, I set the algorithm to stop should the denominator for the next step exceed 10^8.  In that case, the remainder fraction is displayed.  



TI-84 Plus CE Program EGYPTUNT


"2022-09-04 EWS"

Disp "EGYPT>SUM UNIT FRACS"

Input "NUM? ",N

Input "DEN? ",D

N→M:D→C

Disp "SUM: ":Wait .5

While M≠1

int(C/M)+1→B

Disp "1/"+toString(B)

Pause 

M*B-C→M

B*C→C

If C>1E8:Goto 2

End

Disp "1/"+toString(C)

Stop

Lbl 2

Disp "REMAIN:"

Disp toString(M)+"/"+toString(C)


* This assumes your TI-84 Plus CE is at least has the 5.5 operating system.


HP 71B Program EGYPTUNT


100 DISP "EGYPT>SUM UNIT FRACS" @ WAIT .5

105 DESTROY N,D,C,M

110 INPUT "NUM? ";N

115 INPUT "DEN? ";D

120 M=N @ C=D

125 DISP "SUM=" @ WAIT .5


200 B=INT(C/M)+1

205 DISP "1/"&STR$(B) @ PAUSE

210 M=M*B-C @ C=C*B

215 IF C>10^8 THEN 400

220 IF M#1 THEN 200


300 DISP "1/"&STR$(C)

305 STOP


400 DISP "REMAIN: " @ WAIT .5

405 DISP STR$(M)&"/"&STR$(C)

410 STOP


Examples:


6/7

NUM = 6

DEN = 7

Results:  1/2, 1/3, 1/42


6/7 = 1/2 + 1/3 + 1/42


181/360

NUM = 181

DEN = 360

Results: 1/2, 1/361, 1/129961, REMAIN: 2/33779463120


Note:  Please be aware that this Greedy Algorithm  is only one approach and just because we get a REMAIN message does not conclude that the fraction cannot be broken into a sum of unit fractions.  For example:  181/360 = 1/5 + 1/8 + 1/9 + 1/15


See the source below for more information.


"Greedy algorithm for Egyptian fractions" Wikipedia.  Edited December 10, 2021.  Last Accessed September 4, 2022.  https://en.wikipedia.org/wiki/Greedy_algorithm_for_Egyptian_fractions


Eddie


Halloween is just around the corner!


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. 


HP 71B, TI 84 Plus CE: Sum of Egyptian Fractions

HP 71B, TI 84 Plus CE:  Sum of Egyptian Fractions


Introduction 


An Egyptian fraction consists of a sum of unit fractions.  A unit fraction is a fraction with 1 in its numerator and a positive integer in its denominator.   


Today's blog entry will calculate the Egyptian fraction given unit fractions, full simplified.   On tomorrow's entry, we will attempt the reverse process, breaking down an Egyptian fraction into a sum of unit fractions.


N/D = 1/A1 + 1/A2 + 1/A3 + 1/A4 + ....


The Algorithm


Start out with two unit fractions 1/A1 and 1/A2.  


Let N2/D2 = 1/A1 + 1/A2


Then:

N2/D2 = 1/A1 + 1/A2

N2/D2 = (A1 + A2)/(A1*A2)


Let N3/D3 = 1/A3 + N2/D2


Then:  N3/D3 = (A3*N2 + D2)/(N2*D2)


For any general point:


N_x+1/D_x+1 = (N_x * A_x + D_x)/(A_x * D_x)


This allows the user to input as many unit fractions as allowed.  


TI-84 Plus CE Program EGYPTSUM


Disp "EGYPT FRACTION SUM"

"2022-09-03 EWS"

Input "NO. TERMS? ",S

Input "1/A1? ",A

Input "1/A2? ",B

A+B→N

A*B→D

For(I,3,S)

"1/A"+toString(I)+"? "→Str1

Input Str1,A

A*N+D→N

A*D→D

End

gcd(N,D)→G

N/G→N

D/G→D

Disp "NUM= "+toString(N)

Disp "DEC= "+toString(D)

Disp "FRAC="+toString(N/D)


* This assumes your TI-84 Plus CE is at least has the 5.5 operating system.


HP 71B Program EGYPTSUM 


100 DISP "EGYPT FRACTION SUM" @ WAIT .5

105 DESTROY S,A,B,I,N,D,G

110 INPUT "# TERMS? ";S

115 INPUT "1/A1? ";A

120 INPUT "1/A2? ";B

125 N=A+B @ D=A*B

130 IF S=2 THEN 300


200 FOR I=3 TO S:

205 DISP "1/A"&STR$(I)&"?" @ WAIT .5

210 INPUT "1/A? ";A

215 N=A*N+D

220 D=A*D

225 NEXT I


300 A=N @ B=D

305 G=MOD(A,B)

310 A=B @ B=G

315 IF G THEN 305

320 N=N/A @ D=D/A


400 DISP "NUM= ";N

405 DISP "DEN= ";D

410 DISP "FRAC= ";N/D

415 STOP


The 300-325 section calculates the common greatest divisor, based off the "Greatest Common Divisor" program from 119 Practical Programs for the TRS-80 Pocket Computer (see source below).


Examples:


1/2 + 1/6

# TERMS = 2

Result:  2/3 (NUM = 2, DEN = 3)


1/7 + 1/8 + 1/2 

# TERMS = 3

Result:  43/56 (NUM = 43, DEN = 56)


1/9 + 1/5 + 1/15 + 1/8

# TERMS = 4

Result: 181/360 (NUM = 181, DEN = 360)


Source


Craig, John Clark.  119 Practical Programs For The TRS-80 Pocket Computer  TAB Books Inc.  Blue Ridge Summit, PA.  1982 pg. 133



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. 


Drawing Random Numbers with Playing Cards 


An Easy Way to Get Random Numbers

Need an easy and fun way to draw random is to use a playing deck of cards.  No electricity or potentially expensive electronic devices are needed, and your shuffling skills will improve dramatically.  





Take a regular deck of cards, and you will only need 40 cards.  Get all the Aces, ones through nines, and one set of face cards.   Assign the following cards as the following values:


Aces:  1

Twos:  2

Threes: 3

Fours: 4

Fives: 5

Sixes: 6

Sevens: 7

Eights: 8

Nines: 9

Any set of face card or tens: 0  (I use Jacks, see the pictures above.  You can use Queens, Kings, or Tens)


To get a random number:

1.  Shuffle the deck

2.  Draw up to four cards 

3.  That card becomes the random number.  Insert a decimal point anywhere if appropriate.  


Why only up to four cards?  There are only four digits available per deck.  We are generating a samples with no replacement.  


Sample four digit numbers:

8-clubs, Ace-hearts, 2-clubs, 5-diamonds:  8125

2-diamonds, Ace-clubs, 3-clubs, 5-spades:  2135

4-hearts, 8-spades, 3-diamonds, 9-spades: 4839

4-hearts, 3-diamonds, 9-slides, 8-clubs: 4398

Jacks-clubs, Ace-clubs, 2-diamonds, 2-spades: 0122


How many possible permutations are possible with this deck?

2 digits:  nPr(40, 2) = 1560

3 digits:  nPr(40, 3) = 59,280

4 digits:  nPr(40, 4) = 2,193,360



Can we create a program to generate random numbers using this method?  

Yes.   I am using the TI-84 Plus CE to for this program.   The TI-84 has a randIntNoRep function, which generates a list of random integers without replacement.   The nice part of the is we are working with base 10, so the use of a remainder function will give the results we want: 0 through 9.  


Syntax:


Random Sample of Integers Without Replacement:

randIntNoRep(low, high, size of the sample)


Remainder function, which can be used as the modulus function.

remainder(x, y):  returns the remainder of x ÷ y


The program RANDDECK will generate a list and draw a histogram.


TI-84 Plus CE Program:  RANDDECK





"2022-08-16 EWS"

ClrHome

Disp "MAKE A 4 DIGIT,","NUMBER FROM A DECK 0-9"

Input "NO OF TRIALS: ", N

For(I,1,N)

randIntNoRep(1,40,4)→L6

remainder(L6,10)→L6

sum(L6*{1000,100,10,1})→N

If I=1

Then

{N}→L5

Else

augment(L5,{N})→L5

End

End

Pause L5

ClrHome

Disp "PRESS [ENTER] TO"

Pause "DISPLAY HISTOGRAM"

Plot1(Histogram,L5,1,BLUE)

PlotsOn 1

ZoomStat


Here is an example.



Until next time,


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. 


LSQ2: An update to LSQ (Casio fx-9750GIII, TI-84 Plus CE)

LSQ2:  An update to LSQ (Casio fx-9750GIII, TI-84 Plus CE)


Least Square Matrix and Correlation


The program LSQ2 fits the allows to fit data to a function with minimal error possible. 


Multiple Linear Regression:

f(x1, x2, x3, ...) = b0 + b1 * x1 + b2 * x2 + b3 * x3 + ....


Polynomial Regression:

f(x) = b0 + b1 * x + b2 * x^2 + b3 * x^3 + ...


General:

f(x) = b0 + b1 * g1(x) + b2 * g2(x) + b3 * g3(x) + ...


f(x1, x2, x3, ...) = b0 * g0(x1, x2, x3, ...) + b1 * g1(x1, x2, x3, ...) + ...


The Matrices X, Y, and B



X is your data matrix and is set up as columns:


[  g0(x),  g1(x),  g2(x), ... ]


Where the function g(x) represents functions applied to every data point x_i.  


Example 1:   f(x) = b0 + b1 * x 


The columns of the data matrix are set up as:

[ 1,  x ]


A column of ones set up solving for a constant.


Example 2:  f(x) = b0 + b1 * x + b2 * x^2


The columns of the data matrix are set up as:

[ 1, x, x^2 ]


Example 3:  f(x0, x1) = b0 + b1 * x1 + b2 * x2


The columns of the data matrix are set up as:

[ 1, x1, x2 ]  (note, not x squared in this case)



Y is the answer matrix, of size n rows and 1 column.  There are n data points. We are fitting the function to y_i.


B is the coefficient matrix, consisting of values b0, b1, b2, ....



Simply put, to find B using the least squares method given the data points:


B = (X^T X)^-1 X^T Y


X^T is the transpose matrix of X



How well does the function fit?  


We can predict y values by multiplying X by B.  


P' = X B 



Determining Coefficient of Correlation:


r^2 = SSreg ÷ SStot = [ B^T X^T Y - (O Y)^2 ÷ n ] ÷ [ Y^T Y - (O Y)^2 ÷ n ]

where O is a ones matrix [[ 1, 1, 1, 1, ... ]] of size 1 x n.  



Casio fx-9750GIII Program:  LSQ2


From the text file:  


'ProgramMode:RUN

ClrText

"2022_-_07_-_19 EWS"

"LEAST SQUARES"

"_Mat _X"?->Mat X

"_Mat _Y"?->Mat Y

Dim Mat Y->List 26

List 26[1]->N

(Trn Mat X*Mat X)^-1*Trn Mat X*Mat Y->Mat B

"_Mat _B:"Disps

Mat BDisps

{1,N}->Dim Mat O

Fill(1,Mat O)

Mat O*Mat Y->Mat S

Mat S*Mat S/N->Mat S

(Trn Mat B*Trn Mat X*Mat Y)-Mat S->Mat R

Mat R*(Trn Mat Y*Mat Y-Mat S)^-1->Mat R

"R_^<2>_:"Disps

Mat R



Listing:


ClrText

"2022-07-19 EWS"

"LEAST SQUARES"

"Mat X"? → Mat X

"Mat Y"? → Mat Y

Dim Mat Y → List 26

List 26[1] → N

(Trn Mat X × Mat X)^-1 × Trn Mat X × Mat Y → Mat B

"Mat B:" ⊿

Mat B ⊿

{1, N} → Dim Mat O

Fill(1, Mat O)

Mat O × Mat Y → Mat S

Mat S × Mat S ÷ N → Mat S

(Trn Mat B × Trn Mat X × Mat Y) - Mat S → Mat R

Mat R × (Trn Mat Y × Mat Y - Mat S)^-1 → Mat R

"R^2:" ⊿

Mat R


Matrices:

Mat X:  data matrix, X

Mat Y:  answer matrix, Y

Mat B: coefficient matrix, B

Mat O: ones matrix

Mat S:  used for calculation

Mat R:  correlation




TI-84 Plus CE Program:  LSQ2  (TI-Basic)



Listing:

"2022-07-19 EWS"
ClrHome
Disp "LEAST SQUARES"
Input "[X]? ", [J]
Input "[Y]? ", [I]
dim([I]) → L6
L6(1) → N
([J]^T [J])^-1 [J]^T [I] → [B]
Disp "[B]: "
Pause [B]
{1,N} → dim([H])
Fill(1,[H])
[H] [I] → [G]
[G] [G] * N^-1 → [G]
[B]^T [J]^T [I] - [G] → [A]
[A] * ([I]^T [I] - [G])^-1 → [A]
Disp "R^2: "
Disp [A]

List:
L6:  [ 2nd ] [ 6 ]

Matrices:
[J]:  data matrix, X
[I]:  answer matrix, Y
[B]: coefficient matrix, B
[H]: ones matrix
[G]:  used for calculation
[A]:  correlation


Examples

Example 1:

Equation: y = b0 + b1 * x1 + b2 * x2

X = [ [ 1, 1, 3 ] [ 1, 2, 4 ] [ 1, 5, 6 ] [ 1, 7, 3 ] [ 1, 7, 2 ] ]
Y = [ [ 0.86 ] [ 0.89 ] [ 0.95 ] [ 0.98 ] [ 0.96 ] ]

Coefficients:  [ [ b0 ] [ b1 ] [ b2 ] ]
B = [ [ 0.8257514451 ] [ 0.01836705202 ] [ 5.953757225E-3 ] ]

Correlation: [ [ 0.9875030926 ] ]

Example 2:

Equation: y = b0 + b1 * x + b2 * x^2

X = [ [ 1, 1, 1^2 ] [ 1, 2, 2^2 ] [ 1, 3, 3^2 ] [ 1, 4, 4^2 ] [ 1, 5, 5^2 ] [ 1, 6, 6^2 ] ]
Y = [ [ 1000 ] [ 1294 ] [ 1511 ] [ 1233 ] [ 1006 ] [ 879 ] ]

Coefficients:
B = [ [ 681.7 ] [ 435.2107143 ] [ -69.30357143 ] ]

Correlation: [ [ 0.8119609681 ] ]


Summary

Function to fit:   
f(x1, x2, x3 ... ) = b0 + b1 * g1(x1, x2, x3, ...) + b2 * g2(x1, x2, x3, ...) + ...

X = data matrix
Y = answer matrix, size n x 1
B = coefficient matrix

Determining the Coefficients:   B = (X^T X)^-1 X^T Y

Predicting Values:  P = X B

Determining Coefficient of Correlation:

r^2 = SSreg ÷ SStot = [ B^T X^T Y - (O Y)^2 ÷ n ] ÷ [ Y^T Y - (O Y)^2 ÷ n ]
where O is a ones matrix [[ 1, 1, 1, 1, ... ]] of size 1 x n.  

Source

Abdi, Hervè.  "Multiple Correlation Coefficient"  Program in Cognition and Neurosciences   https://personal.utdallas.edu/~herve/Abdi-MCC2007-pretty.pdf   Retrieved July 17, 2022.  


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. 

TI 84 Plus CE TI-Basic and TI Nspire CX II Python: Gamma by Multiplication Recursion Property

TI 84 Plus CE TI-Basic and TI Nspire CX II Python:   Gamma by Multiplication Recursion Property


Introduction


The program calculates the gamma function for any real positive number in tenths by the multiplication recursion:


Γ(x + 1) = x * Γ(x)


For example:  


Γ(2.5)

= 1.5 * Γ(1.5)

= 1.5 * 0.5 * Γ(0.5)

≈ 1.5 * 0.5 * 1.772453851

≈ 1.329340388


Reduce x by 1 until 1 is in between 0.1 and 1. 


Gamma Values:


Γ(0.1) = 9.513507699

Γ(0.2) = 4.590843712

Γ(0.3) = 2.991568988

Γ(0.4) = 2.218159544

Γ(0.5) = 1.772453851

Γ(0.6) = 1.489192249

Γ(0.7) = 1.298055333

Γ(0.8) = 1.164229714

Γ(0.9) = 1.068628702

Γ(1) = 1


TI-84 Plus CE Program: GAMMATEN

TI-Basic


Notes:


*  To get the small L to create lists with custom names, get the character with the key strokes:  [ 2nd ] ( list ), OPS, B.  L.   In this listing, I will write L^ to symbolize the lower case L.


* L^TEN is a custom list.


Program listing:


{9.513507699, 4.590843712, 2.991568988, 

2.218159544, 1.772453851, 1.489192249,

1.298055333, 1.164229714, 1.068628702

1}→L^TEN

ClrHome

Disp "GAMMA X (NEAREST 0.1)"

Input "X≥0.1, X?",X

round(X,1)→X

fPart(X)*10→F

If F=0:10→F

1→G

While X>1

G*(X-1)→G

X-1→X

End

G*L^TEN(F)→G

Disp "EST. GAMMA: ", G


TI-NSpire Python Script:  gammaten.py


The code is defined as a function.   


def gammaten(x):

  lten=[9.513507699]

  lten.append(4.590843712)

  lten.append(2.991568988)

  lten.append(2.218159544)

  lten.append(1.772453851)

  lten.append(1.489192249)

  lten.append(1.298055333)

  lten.append(1.164229714)

  lten.append(1.068628702)

  lten.append(1)

  #print("gamma(x) to the nearest 0.1")

  x=round(x,1)

  f=round(10*(x-int(x))-1)

  g=1

  while x>1:

    x-=1

    g*=x

  g*=lten[f]

  return [g,f]


# list[-1] gets last item too

# round integers for accurate results!

# 2022-06-13 EWS


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. 


TI 84 Plus CE and HP 33S: Scaled Data for Statistics

TI 84 Plus CE and HP 33S:  Scaled Data for Statistics


Introduction and the Mathematics


The goal of the programs posted today is to take a data set of real numbers and scale it down to the range [1,10].  Why?  Sometimes scaling data by applying a linear transformation, it could make curve fitting and data analysis more accessible and open up regression analysis previously not available, such as logarithmic or power regression.   


Let:


max = maximum value of the data set

min = minimum  value of the data set


And:


min * a + b = 1

max * a + b = 10


Solving for a and b:


a = 9/(max - min)

b = 1 - a * min = 10 - a * max


Apply this transformation to the data set to get:


x' = a*x + b


And to convert back:


x = (b - x')/a



TI-84 Plus CE Program:  DSCALE   (TI-Basic)


Disp "DATA SCALE TO [1,10]","BY EDWARD SHORE"

Input "XLIST: ",L5

9/(max(L5)-min(L5))→A

1-A*min(L5)→B

Disp "FORMULA:","X'="+toString(A)+"X+"+toString(B)

Pause

A*L5+B→L6

Disp "SCALED DATA:"

Pause L6


Note:

L5:  List 5, used for input, [ 2nd ] [ 5 ]

L6:  List 6, used for output, [ 2nd ] [ 6 ]


HP 33S Programs


LBL Y:  determine A and B.  Stack:  Y:  max, X:  min

HP 33S Size:  LN = 72, CK = B830


Y0001  LBL Y

Y0002  -

Y0003  LASTx

Y0004  x<>y

Y0005  1/x

Y0006  9

Y0007  ×

Y0008  STO A

Y0009  VIEW A

Y0010  ×

Y0011  1

Y0012  x<>y

Y0013  -

Y0014  STO B

Y0015  VIEW B

Y0016  RTN


LBL X:  Calculate x'

HP 33S Size:  LN = 15, CK = 08B6


X0001  LBL X

X0002  RCL- B

X0003  RCL÷ A

X0004  STOP

X0005  GTO X    // this allows for repeated calculations by pressing R/S


LBL Z:  Calculate x

HP 33S Size: LN = 15, CK = 4552


Z0001  LBL Z

Z0002  RCL× A

Z0003  RCL+ B

Z0004  STOP

Z0005  GTO Z   // this allows for repeated calculations by pressing R/S


Instructions:

1.  Do this first:  max [ ENTER ] min [ XEQ ] Y  

2.  XEQ Z  to calculate X'.  XEQ X to calculate X'. 


X' = A * X + B


Example


Data Set:  [-5, -3, 2, 3, 6]


max = 6

min = -5


(results are rounded to six decimal places)

a = 0.818182

b = 5.090909


Translated Data: 


x to x':

x = -5,  x' = 1.000000

x = -3,  x' = 2.636364

x = 2, x' = 6.727273

x = 3, x' = 7.545455

x = 6, x' = 10.000000


x' to x:

x' = 2.5, x = -3.16667

x' = 5,  x = -0.111111

x' = 7.5, x = 2.944444


Hope you find this helpful.  Next week is a retro review of the HP 33S Calculator, once abhorred now held as valuable.  


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. 


TI-84 Plus CE, TI-Basic and Python: Dynamic and Goal Average

TI-84 Plus CE, TI-Basic and Python:  Dynamic and Goal Average 



Dynamic Average


The dynamic average is defined as:


Σx_i / m   from i = 1 to m, m ≤ n


A new list is created:


1st point has the value of the first data value,

2nd point has the value of the first two data values, 

3rd point has the value of the first three data values,

...

nth point is the arithmetic average of the entire list.


The TI-Basic Version plots the averages in a stat plot, while the Python version returns a list.


Remember:  In TI-Basic, the pointer starts at 1, while with Python, the pointer starts at 0.  Also, my Python programs will require you to enter the number of data points in advance. 


TI-84 Plus CE TI-Basic Program:  DYNAVG


"EWS 2022-04-18"

Input "DATA? ", L1   // [ 2nd ] [ 1 ]

seq(X,X,1,dim(L1),1)→L2   // [ 2nd ] [ 2 ]

cumSum(L1)/L2→L3   // [ 2nd ] [ 3 ]

Func: FnOff : PlotsOff

Plot1(Scatter,L2,L3)

ZoomStat


TI-84 Plus CE Python File: dynavg.py


# 2022-04-20 EWS


d=eval(input("# points? "))

x=[ ]

s=[ ]

a=[ ]


for i in range(d):

  w=eval(input("point "+str(i+1)+"? "))

  x.append(w)

  t=sum(x)

  s.append(t)

  v=t/(i+1)

  a.append(v)


print("cumulative sum:")

print(s)

print("dynamic average:")

print(a)


Example:


Input:  Data Points:  {4, 5.6, 3.9, 5.6, 5.7, 5.8, 7.2, 6.4}

Result: Dynamic Averages: {4, 4.8, 4.5, 4.775, 4.96, 5.1, 5.4, 5.525}





Goal Average


You have a goal, for example:  

*  reach a set number of steps

*  raise a set amount of revenue

*  score a set amount of points during a season of basketball


You have a set amount of times (days, months, years, etc.) (n) and you have a certain amount of data points (m).   Assuming you have time left in your program, what is the remaining amount needed and average per period left?  (This assumes that m < n).  


TI-84 Plus CE TI-Basic Program:  GOALAVG


"2022-04-18 EWS"

Input "GOAL? ", T

Input "TIMES? ", n

Input "DATA? ", L1

sum(L1)→S

dim(L1)→M

If S≥T

Then

Disp "GOAL MADE"

Else

T-S→D

D/(N-M)→A

Disp "TO GO =",D

Disp "AVG =",A

End


TI-84 Plus CE Python File: goalavg.py


# 2022-04-20 EWS


t=eval(input("Goal? "))

n=eval(input("# times? "))

m=eval(input("# data points? "))


s=0

x=[ ] 


for i in range(m):

  w=eval(input("point "+str(i+1)+"? "))

  x.append(w)

  s+=w


if s>=t:

  print("Goal made!")

else:

  d=t-s

  a=d/(n-m)

  print("To go: "+str(d))

  print("Average: "+str(a))


Example:


Input:  

Goal:  100,000

# Times:  14  (n)

# Data Points: 6  (m)

Data:  {5466, 8316, 8821, 9340, 6726, 8011}


Results:

To Go:  53539

Average:  6692.375




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. 


TI-84 Plus CE: All In Chance Game

TI-84 Plus CE:  All In Chance Game


The All In Chance Game


The objective is to get a high score by stopping the 2 x 2 board like this:


A   B

C  D


You score the sum of all four values.   Watch for negative values and zeroes.


Spots B, C, and D range from -2 to 5, while A has four possible values: -5, 0, 5, 10.


How many spins you get?  The game has a spinner from 2 to 7 spins.  


Free spins can be earned.  One way is to stop the board when A = 10.   There are two other ways, can you discover them?  



TI-84 Plus CE Program: ALLIN

(605 bytes)


Full

ClrHome

Output(1,1,"ALL IN GAME")

Output(2,1,"EWS 2022")

Wait 0.5

Output(4,1,"HOW MANY")

Output(5,1,"SPINS?")

Wait 0.5


0

Repeat Ans

randInt(2,7)→S

ClrHome

Output(1,3,"PRESS ANY KEY")

Output(3,3,"SPINS:")

Output(3,11,S)

Wait 0.25

getKey

End


ClrHome

Output(4,3,"YOU GOT")

Output(5,3,S)

Output(5,5,"SPINS!")

Output(7,3,"GOOD LUCK!")

Wait 0.8


0→T

0→M

While S>0

0

Repeat Ans

augment(5*randInt(­1,2,1),randInt(­2,5,3))→L6

ClrHome

Output(1,1,"SPINS LEFT: "+toString(S))

Output(3,4,L6(1))

Output(3,8,L6(2))

Output(6,4,L6(3))

Output(6,8,L6(4))

Output(8,1,"PRESS ANY KEY")

Wait 0.2

getKey

End

sum(L6)→P

T+P→T

If P>M:P→M

If L6(1)=L6(4) or L6(1)=10

Then

Output(1,1,"****FREE SPIN!****")

S+1→S

End

Output(8,1,"YOU GOT "+toString(P)+"         ")

Output(9,1,"TOTAL: "+toString(T))

Output(10,1,"PRESS ENTER")

Pause 

S-1→S

End


ClrHome

Disp "FINAL SCORE: "+toString(T)

Disp "BEST SPIN: "+toString(M)


Notes:


On the line Output(8,1,"YOU GOT "+toString(P)+"         "), extra spaces are needed to "erase" the PRESS ANY KEY message.


0 is entered before the Repeat Ans loop to make Ans "false", allowing for the loop to happen and the player to press any key to exit the loop. See the TI-Basic Developer's page for more details:  http://tibasicdev.wikidot.com/getkey


Source:


"The getKey Command"  TI-BASIC DEVELOPER: The TI-BASIC INFORMATION REPOSITORY.  Retrieved February 6, 2022.  http://tibasicdev.wikidot.com/getkey


This program is made with OS 5.7, but it should work on O.S versions 5.5 and 5.6.  Earlier OS versions may not have the Wait and toString commands.  


L6 refers to List 6, [ 2nd ]  [ 6  ].


Download the file here: 

https://drive.google.com/file/d/1QkrXnt6dR1KgEy-2d9JQxE7jmQS93Drk/view?usp=sharing

HP 32S and HP 32SII Week:  May 2, 2022 - May 6, 2022


Good luck!


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...!!!!