Category:	statistics
Program:	UNIMEANS
Author:		tumnus
Date:		2025-02-22


General Purpose

Computes the mean of sample means of samples from the uniform distribution of random digits from 0 to 9. User specifies the number of samples, the size of each sample, and the bin (class) size for the histogram. Returns the mean of sample means and creates a relative frequency histogram.

Adapted from UCSMP Functions, Statistics & Trigonometry (1992), Section 10-7: Sampling Distributions and the Central Limit Theorem.


Speed Notes

A genuine compiled statistics package such as R, Minitab, or StatView will operate much faster for large samplings than a TI-82. The number of samples m of size n are related quadratically to time. That is, there is a "quadratic time complexity" at play here.

10 samples, size 10:	7 seconds
10 samples, size 100:	1 minute
10 samples, size 1000:	9 minutes


Instructions

1. Select PRGM EXEC UNIMEANS.
2. Enter the number of samples.
3. Enter the size of each sample. 
4. Enter the bin size for the histogram, typically 1 or 0.5.*
4. Press GRAPH to view the histogram.
5. Press STAT Edit to view L1 values and L2 relative frequencies.

You may wish to turn on the grid: WINDOW FORMAT GridOn. 

*If the bin size is less than 0.2, a graphing error will occur. It is possible to increase the bin size after the program has run by selecting WINDOW xScl. For example, if the bin size was 0.5, you can increase xScl to 1. You may need to increase yMax to view the complete histogram.


Reading the Histogram

The x-axis ranges from 0 to 9, ticked off at each bin size.
The y-axis should be interpreted as ranging from 0 to less than 1 (varies), ticked off every 0.1 (for relative frequency).

You may notice that the actual y-values in the histogram are integers, not relative frequencies. Since the TI-82 can only plot integer frequencies, the relative frequencies in L2 were scaled by 100, then put into list L3. Stat plot uses L1 and L3 to display the histogram.


Implications for the Central Limit Theorem (CLT)

The population mean of the uniform distribution of random digits 0 to 9 is 4.5 (mu = 4.5). If we take a sample of n random random digits and find the mean, we get a sample mean. If we take several sample means and find their mean, we get the mean of the sample means: M.

For example, if we enter 10 samples of size 5, a possible M is 4.76. If we enter 10 samples of size 100, a possible M is 4.603. If we try 10 samples of size 1000 (it will take a while), a possible M is 4.496.

SAMPLES:	SIZE: (n)	MEAN:
10		5		4.76		Close to 4.5.
10		100		4.603		Closer to 4.5.
10		1000		4.496		Very close to 4.5.

The takeaway: as the size n of the samples increases, the mean of sample means M approaches the population mean mu, 4.5.

The histogram is a relative frequency distribution of the sample means. If we increase the sample size n, the distribution of means changes. Take note of the spread, shape, and symmetry of each histogram for the following inputs.

SAMPLES:	SIZE: (n)	BIN:
30		2		.2
30		5		.2
30		10		.2
30		50		.2

You should notice that as the size of the samples increases, more of the data clusters around the population mean 4.5, and the spread decreases. This should tell you that the measure of spread, the standard deviation of the means is decreasing as the sample size n is increasing.

As n increases, the shape of each histogram also begins to look more symmetrical around the population mean 4.5, sloping away on each side. It begins to approximate the shape of a normal curve.


Variables & Settings Used

Lists:		L1, L2, L3
Alpha:		A, B, C, I, M, N, S, T, X
Window:		xMin, xMax, xScl, yMin, yMax, yScl
ClrList:	Lists L1, L2, L3 will be cleared.
FnOff:		All functions will be off.
PlotsOff:	All plots other than Plot1 will be off.
Plot1:		Plot1 will be modified.


Program Details
The symbol -> means "store as" (the assignment arrow from STO key).

ClrHome
Disp "L1,L2,L3"
Disp "WILL BE CLEARED",""
Input "SAMPLES: ",M		Get number of samples.
Input "SIZE:    ",N		Get sample size.
Input "BIN:     ",C		Get bin size of histogram.
ClrHome
Disp "SAMPLE:","","SIZE:"
Output(2,9,"/")			Display sample count ratio.
Output(2,10,M)
Output(3,10,N)			Display sample size.
ClrList L1,L2,L3
seq(X,X,0,9,C)->L1		Fill L1 with bins.
int ((9+C)/C)->dim L2		Fill L2 with zeros matching number of bins.
0->S				Initialize sum of means.
For(A,1,M,1)			Start sampling loop.
0->T				Reset sample sum.
For(B,1,N,1)			Start sample generation loop.
int rand10+T->T			Generate random digit, add to sample sum T.
End				Loop back to sample sum.
T/N->T				Compute mean, store as T.
int ((T+C)/C)->I		Compute correct bin index for mean.
L2(I)+1->L2(I)			Increment bin in L2 for frequency.
S+T->S				Add mean to sum of means.
Output(1,10,A)			Display sample count.
End				Loop back to sampling loop or exit.
L2/M->L2			Convert L2 to frequencies.
round(100L2,0)->L3		Scale L2 frequencies to integers, put in L3.
PlotsOff 
FnOff 
PlotsOn 1
Plot1(Histogram,L1,L3)
0->Xmin
9->Xmax
C->Xscl				Set x-axis tick marks to bin size.
0->Ymin
5+max(L3)->Ymax			Set max y-axis to 5 over maxiumum frequency.
10->Yscl
Disp "","MEAN:"
Output(5,10,round(S/M,3)	Display mean of sample means.
Disp "GRAPH FOR HIST"
