Saturday, June 4, 2022

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. 


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