|AHELP for CIAO 4.2||
Calculate the group number for each element in the array.
Integer_Type grpnum = grpGetGrpNum( Array_Type grouping )
This function calculates which group each element in the input array belongs to, where the groups are numbered from 1. The return value is an array whose length equals that of the input data (the grouping argument) and each element within a group contains the same value. As an example,
grpGetGrpNum( [1,-1,1,-1,1,1] )
will return the array
since the groups consist of the first two elements, then the next two elements, with the last two elements being un-grouped.
The group module is not available by default; to use it in a S-Lang program, it must be loaded using the S-Lang require() function:
slsh> igrp = grpGetGrpNum( grp );
The igrp array will contain the group number for each element of the input array, for the grouping scheme stored in the grp array, and has the same size as the grp array.
slsh> x = [0.5:6.0:0.05]; slsh> y = 3 + 30 * exp( - (x-2.0)^2 / 0.1 ); slsh> ( grp, qual ) = grpNumCounts( y, 15 ); slsh> yavg = grpGetGroupSum( y, grp ) / grpGetChansPerGroup( grp ); slsh> igrp = grpGetGrpNum( grp ); slsh> i = where( grp == 1 and qual == 0 );
Here we take the function
y = 3 + 30 * exp( -(x-2)^2 / 0.1 )
and group it by 15 counts per group.
See the bugs page for the group library on the CIAO website for an up-to-date listing of known bugs.