Package com.tdunning.math.stats

## Class Centroid

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

All Implemented Interfaces:
  `java.lang.Comparable<Centroid>`

    public class Centroid
    extends java.lang.Object
    implements java.lang.Comparable<Centroid>

A single centroid which represents a number of data points.

### Constructor Summary

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

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`void` `add​(double x, int w)`
`void` `add​(double x, int w, java.lang.Iterable<? extends java.lang.Double> data)`
`int` `compareTo​(Centroid o)`
`int` `count()`
`static Centroid` `createWeighted​(double x, int w, java.lang.Iterable<? extends java.lang.Double> data)`
`java.util.List<java.lang.Double>` `data()`
`int` `hashCode()`
`int` `id()`
`void` `insertData​(double x)`
`double` `mean()`
`java.lang.String` `toString()`

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

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

### Constructor Detail

#### 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 Detail

#### add

    public void add​(double x,
                    int w)

#### mean

    public double mean()

#### count

    public int count()

#### id

    public int id()

#### toString

    public java.lang.String toString()

Overrides:
  `toString` in class `java.lang.Object`

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `java.lang.Object`

#### compareTo

    public int compareTo​(Centroid o)

Specified by:
  `compareTo` in interface `java.lang.Comparable<Centroid>`

#### data

    public java.util.List<java.lang.Double> data()

#### insertData

    public void insertData​(double x)

#### createWeighted

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

#### add

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