cmd_twovar Function (ROM Call 0x398)

AMS 1.01 or higher bascmd.h

void cmd_twovar (ESI StatData);

Executes TI-Basic 'TwoVar' command.

cmd_twovar calculates two-variable statistics and updates all statistics variables (see TI-Basic manual for more info). The StatData parameter must point to a structure on the expression stack which describes where the actual data is stored. This structure may have one of the following four layouts (StatData should point to the last item):

NOTHING_TAG NOTHING_TAG NOTHING_TAG y_list_name x_list_name
NOTHING_TAG NOTHING_TAG freqs_name y_list_name x_list_name
END_TAG categories_list LIST_TAG categories_name NOTHING_TAG y_list_name x_list_name
END_TAG categories_list LIST_TAG categories_name freqs_name y_list_name x_list_name

x_list_name is the VAT symbol name (see SYMSTR and Tags for more info) of a TI-Basic list variable which contains the x values. y_list_name is the VAT symbol name of a TI-Basic list variable which contains the y values. freqs_name (if present) is the VAT symbol name of a TI-Basic list variable which contains the frequencies (all frequencies are assumed to be 1 if freqs_name is not present). categories_name (if present) is the VAT symbol name of a TI-Basic list which contains the category code for each item. categories_list represents a list of integer items which determine which categories will be included (this makes sense only when categories_name is used).

For example, assuming that two TI-Basic list variables "xdata" and "ydata" contain the x and y values, you can calculate simple two-variable statistics using the following code fragment:

push_quantum (NOTHING_TAG);
push_quantum (NOTHING_TAG);
push_quantum (NOTHING_TAG);
push_expression (SYMSTR ("ydata"));
push_expression (SYMSTR ("xdata"));
cmd_twovar (top_estack);
After this, you can retrieve the calculated regression data by accessing TI-Basic system variables like "minX" directly (using VarRecall, for example), or you can display the calculated data using cmd_showstat.

The symbol names x_list_name, y_list_name, freqs_name, and categories_name may also be "c1".."c99". In this case, they represent columns in the last data variable shown in the Data/Matrix editor. In all cases, the lists represented by x_list_name, y_list_name, freqs_name, and categories_name must have the same dimension.


Uses: HeapAlloc, HeapDeref, HeapFree, HeapFreeIndir, HeapRealloc, HLock, ER_catch, ER_success, ER_throwVar, estack_to_ushort, next_expression_index, ST_helpMsg, XR_stringPtr, ceil, fabs, floor, sqrt, ck_valid_float, estack_to_float, is_cFloat_agg, OO_GetAppAttr, PlotInit, PlotPut, RM_Type, statFree, statStart, MakeWinRect, WinFill, WinFillTriangle, WinLine, WinRect, WinStrXY, _bcd_math, ROM Call 0x46B, ROM Call 0x4CB


See also: cmd_onevar, cmd_linreg, cmd_quadreg, cmd_cubicreg, cmd_quartreg, cmd_powerreg, cmd_expreg, cmd_lnreg, cmd_sinreg, cmd_medmed, cmd_logistic