Skip to the navigation links
Last modified: December 2009

URL: http://cxc-newtest.cfa.harvard.edu/ciao4.2/grpnumbins.html
AHELP for CIAO 4.2

grpNumBins

Context: group

Synopsis

Group an array into a set of equal-width groups (by number of groups).

Syntax

grpNumBins( Integer_Type numChans, Integer_Type numGroups )
grpNumBins( Integer_Type numChans, Integer_Type numGroups, Array_Type
tabStops )

Returns: ( Array_Type grouping, Array_Type quality )

Description

This function returns the grouping and quality arrays that represent an array of numChans elements grouped into numGroups groups. The optional parameter tabStops is an array which lists those elements that should be ignored. The tabStops array must be the same length as the channels array. A value of 0 means no tab; a value of 1 means that there is a tab stop.

This function provides the same functionality as the NUM_BINS option of dmgroup. The grpBinWidth() function allows you to fix the width of the group rather than the number of groups.

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:

  require("group");

Example 1

slsh> (g,q) = grpNumBins( 10, 2 );

This example calculates the grouping and quality arrays that represent an array of 10 elements grouped into 2 groups.

Example 2

slsh> x = [0.5:6.0:0.05];
slsh> y = 3 + 30 * exp( - (x-2.0)^2 / 0.1 );
slsh> (g,q) = grpNumBins( length(y), 10 );
slsh> ysum = grpGetGroupSum( y, g );
slsh> nchan = grpGetChansPerGroup( g );
slsh> i = where( g == 1 );
slsh> yavg = ysum[i] / nchan[i];

Here we take the function

y = 3 + 30 * exp( -(x-2)^2 / 0.1 )

and group it so that there are 10 groups.

Bugs

See the bugs page for the group library on the CIAO website for an up-to-date listing of known bugs.

See Also

group
grpadaptive, grpadaptivesnr, grpbin, grpbinfile, grpbinwidth, grpgetchanspergroup, grpgetgroupsum, grpgetgrpnum, grpmaxslope, grpminslope, grpnumbins, grpnumcounts, grpsnr
modules
group_slang

Last modified: December 2009