Package com.tdunning.math.stats

# Class Centroid

java.lang.Object
com.tdunning.math.stats.Centroid

All Implemented Interfaces:
  `Comparable<Centroid>`

public class Centroid extends Object implements Comparable<Centroid>
A single centroid which represents a number of data points.

## Constructor Summary

Constructors
Constructor
Description
`Centroid(double x)`
`Centroid(double x, int w)`
`Centroid(double x, int id, boolean record)`
`Centroid(double x, int w, int id)`

## Method Summary

Modifier and Type
Method
Description
`void`
`add(double x, int w)`
`void`
`add(double x, int w, Iterable<? extends Double> data)`
`int`
`compareTo(Centroid o)`
`int`
`count()`
`static Centroid`
`createWeighted(double x, int w, Iterable<? extends Double> data)`
`List<Double>`
`data()`
`int`
`hashCode()`
`int`
`id()`
`void`
`insertData(double x)`
`double`
`mean()`
`String`
`toString()`

### Methods inherited from class java.lang.Object

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

## Constructor Details

### Centroid

public Centroid(double x)

### Centroid

public Centroid(double x, int w)

### Centroid

public Centroid(double x, int w, int id)

### Centroid

public Centroid(double x, int id, boolean record)

## Method Details

### add

public void add(double x, int w)

### mean

public double mean()

### count

public int count()

### id

public int id()

### toString

public String toString()

Overrides:
  `toString` in class `Object`

### hashCode

public int hashCode()

Overrides:
  `hashCode` in class `Object`

### compareTo

public int compareTo(Centroid o)

Specified by:
  `compareTo` in interface `Comparable<Centroid>`

### data

public List<Double> data()

### insertData

public void insertData(double x)

### createWeighted

public static Centroid createWeighted(double x, int w, Iterable<? extends Double> data)

### add

public void add(double x, int w, Iterable<? extends Double> data)