# Class TableStats

java.lang.Object
uk.ac.starlink.ttools.filter.TableStats

public class TableStats extends Object
Aggregates column statistics for a table. Factory methods are provided to accumulate statistics from table data.

Since:
  3 Dec 2020
Author:
  Mark Taylor

## Field Summary

Fields
Modifier and Type
Field
Description
`static final double`
`MAD_SCALE`
Value by which Median Absolute Deviation is scaled to estimate SD.

## Constructor Summary

Constructors
Constructor
Description
`TableStats(UnivariateStats[] colStats)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`static double[]`
`calculateMads(uk.ac.starlink.table.StarTable table, uk.ac.starlink.table.RowRunner runner, Supplier<Quantiler> qSupplier, double[] medians)`
Calculates Median Absolute Deviations for each table column.
`static TableStats`
`calculateStats(uk.ac.starlink.table.StarTable table, uk.ac.starlink.table.RowRunner runner, Supplier<Quantiler> qSupplier, boolean doCard)`
Calculates statistics from a given table.
`UnivariateStats[]`
`getColumnStats()`
Returns the array of per-column statistics accumulators.
`long`
`getRowCount()`
Returns the number of rows for which statistics have been accumulated.

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### MAD_SCALE

public static final double MAD_SCALE
Value by which Median Absolute Deviation is scaled to estimate SD.

See Also:
  - Constant Field Values

## Constructor Details

### TableStats

public TableStats(UnivariateStats[] colStats)
Constructor.

Parameters:
  `colStats` - array of per-column statistics accumulators

## Method Details

### getColumnStats

public UnivariateStats[] getColumnStats()
Returns the array of per-column statistics accumulators.

Returns:
  column stats

### getRowCount

public long getRowCount()
Returns the number of rows for which statistics have been accumulated.

Returns:
  row count

### calculateStats

public static TableStats calculateStats(uk.ac.starlink.table.StarTable table, uk.ac.starlink.table.RowRunner runner, Supplier<Quantiler> qSupplier, boolean doCard) throws IOException
Calculates statistics from a given table.

Parameters:
  `table` - table supplying data
  `runner` - controls sequential/parallel processing
  `qSupplier` - supplies quantile accumulators if quantiles are required, otherwise null
  `doCard` - whether to count distinct values
Throws:
  `IOException`

### calculateMads

public static double[] calculateMads(uk.ac.starlink.table.StarTable table, uk.ac.starlink.table.RowRunner runner, Supplier<Quantiler> qSupplier, double[] medians) throws IOException
Calculates Median Absolute Deviations for each table column.

Parameters:
  `table` - input table
  `runner` - controls sequential/parallel processing
  `qSupplier` - supplies quantile accumulators
  `medians` - per-column array of median values; MADs will be calculated only for elements with non-null values
Returns:
  per-column array of MADs
Throws:
  `IOException`