V
- value typeW
- weight typepublic class WeightedMeanAndSum<V extends Number,W extends Number> extends Object
Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
Constructor and Description |
---|
WeightedMeanAndSum()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
<S> WeightedMeanAndSum<V,W> |
add(Collection<S> collection,
Function<S,V> values,
Function<S,W> weights)
Adds each value with a weight given by a function.
|
WeightedMeanAndSum<V,W> |
add(Collection<V> collection,
Function<V,W> weights)
Adds each value with a weight given by a function.
|
WeightedMeanAndSum<V,W> |
add(Iterable<V> values,
Iterable<W> weights)
Adds a weighted value for each element.
|
WeightedMeanAndSum<V,W> |
add(Map<V,W> map)
Adds each weighted value from a map.
|
WeightedMeanAndSum<V,W> |
add(V[] values,
W[] weights)
Adds a weighted value for each element.
|
WeightedMeanAndSum<V,W> |
add(V value,
W weight)
Adds a value with weight.
|
double |
getMean()
Returns the weighted mean of available data.
|
double |
getSum()
Returns the weighted sum of available data.
|
double |
getWeightSum()
Returns the sum of the weights.
|
public final double getMean()
public final double getSum()
public final double getWeightSum()
public final WeightedMeanAndSum<V,W> add(V value, W weight)
value
- V; valueweight
- W; weightpublic final WeightedMeanAndSum<V,W> add(Iterable<V> values, Iterable<W> weights)
HashMap
or HashSet
.values
- Iterable<V>; valuesweights
- Iterable<W>; weightsIllegalArgumentException
- if the number of values and weights are unequalpublic final WeightedMeanAndSum<V,W> add(V[] values, W[] weights)
values
- V[]; valuesweights
- W[]; weightspublic final WeightedMeanAndSum<V,W> add(Map<V,W> map)
map
- Map<V, W>; mappublic final WeightedMeanAndSum<V,W> add(Collection<V> collection, Function<V,W> weights)
collection
- Collection<V>; valuesweights
- Function<V, W>; weightspublic final <S> WeightedMeanAndSum<V,W> add(Collection<S> collection, Function<S,V> values, Function<S,W> weights)
S
- type of source objectcollection
- Collection<S>; collection of source objectsvalues
- Function<S, V>; valuesweights
- Function<S, W>; weightsCopyright © 2014–2019 Delft University of Technology. All rights reserved.