Appendix A: System Routines — Lists and Matrices
697
TI
-
89 / TI
-
92 Plus Developer Guide
Not for Distribution
Beta Version January 26, 2001
push_mean
Declaration:
void
push_mean
(EStackIndex
mat_lst_idx
)
Category(ies):
Lists and Matrices, Statistics, Math
Description:
Pushes onto the estack the mean of the input list or matrix. For lists pushes
the average of all elements on the estack. For matrices pushes a row
vector containing the averages of the matrix columns.
Inputs:
mat_lst_idx
— Indexes the input matrix or list.
Outputs:
None
Assumptions:
None
Side Effects:
May expand expression stack, cause heap compression, or throw an error.
Availability:
On AMS 2.00 and higher.
TI-89 / TI-92 Plus
Differences:
None
See Also: push_median
Example:
This example takes a list pointed to by lst_idx (a test list is pushed on the
estack). It then creates a new list on the estack where each element is the
square of the difference between the element and the mean. This list is
then saved in the variable L3.
EStackIndex lst_idx, mean_idx, sum_idx;
BYTE L3[] = {0,'l','3',0};
push_quantum(END_TAG); push_Float(2); push_Float(5); push_Float(8);
push_quantum(LIST_TAG);
lst_idx = top_estack; /* Point to input list */
push_mean( lst_idx );
negate_top ();
mean_idx = top_estack; /* Point to -(mean(list)) */
/* Create a list where each element is the square of its difference from the mean */
push_quantum (END_TAG);
lst_idx = lst_idx - 1; /* skip LIST_TAG */
while (END_TAG != *lst_idx) {
push_sum( lst_idx, mean_idx );
lst_idx = next_expression_index( lst_idx );
sum_idx = top_estack;
push_product( top_estack, top_estack );
delete_expression( sum_idx );
}
push_quantum( LIST_TAG );
VarStore( L3+3, STOF_ESI, 0, top_estack );