MT
- mean typeV
- value typeW
- weight typepublic abstract class AbstractMean<MT,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 |
---|
AbstractMean()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
<S> AbstractMean<MT,V,W> |
add(Collection<S> collection,
Function<S,V> values,
Function<S,W> weights)
Adds each value (obtained by calling the
values function on each object in a Collection) with a weight
(obtained by calling the weights function on the same object from the Collection). |
AbstractMean<MT,V,W> |
add(Collection<V> collection,
Function<V,W> weights)
Adds each value with a weight obtained by calling the provided
weights function. |
AbstractMean<MT,V,W> |
add(Iterable<V> values)
Add values with weight 1.
|
AbstractMean<MT,V,W> |
add(Iterable<V> values,
Iterable<W> weights)
Adds weighted values.
|
AbstractMean<MT,V,W> |
add(Map<V,W> map)
Adds each key value from a map weighted with the mapped to value.
|
AbstractMean<MT,V,W> |
add(V value)
Add a value with weight 1.
|
AbstractMean<MT,V,W> |
add(V[] values)
Add values with weight 1.
|
AbstractMean<MT,V,W> |
add(V[] values,
W[] weights)
Adds weighted values.
|
AbstractMean<MT,V,W> |
add(V value,
W weight)
Adds a value with weight.
|
protected abstract AbstractMean<MT,V,W> |
addImpl(V value,
Number weight)
Adds a value with weight.
|
abstract double |
getMean()
Returns the weighted mean of accumulated data.
|
double |
getSum()
Returns the weighted sum of available data.
|
double |
getSumOfWeights()
Returns the sum of the weights.
|
(package private) void |
increment(double value,
double weight)
Accumulate some data.
|
public abstract double getMean()
final void increment(double value, double weight)
value
- double; the value to add to the weightedSumOfValues
weight
- double; the weight to assign to the value
public final double getSum()
public final double getSumOfWeights()
public final AbstractMean<MT,V,W> add(V value, W weight)
value
- V; the valueweight
- W; the weightprotected abstract AbstractMean<MT,V,W> addImpl(V value, Number weight)
value
- V; the valueweight
- Number; the weightpublic final AbstractMean<MT,V,W> add(V value)
value
- V; the valuepublic final AbstractMean<MT,V,W> add(Iterable<V> values, Iterable<W> weights) throws IllegalArgumentException
HashMap
or HashSet
.values
- Iterable<V>; valuesweights
- Iterable<W>; weightsIllegalArgumentException
- if the number of values is not equal to the number of weightspublic final AbstractMean<MT,V,W> add(V[] values, W[] weights) throws IllegalArgumentException
values
- V[]; valuesweights
- W[]; weightsIllegalArgumentException
- if the number of values is not equal to the number of weightspublic final AbstractMean<MT,V,W> add(Map<V,W> map)
map
- Map<V, W>; mappublic final AbstractMean<MT,V,W> add(Collection<V> collection, Function<V,W> weights)
weights
function.collection
- Collection<V>; valuesweights
- Function<V, W>; weightspublic final <S> AbstractMean<MT,V,W> add(Collection<S> collection, Function<S,V> values, Function<S,W> weights)
values
function on each object in a Collection) with a weight
(obtained by calling the weights
function on the same object from the Collection).S
- type of source objectcollection
- Collection<V>; collection of source objectsvalues
- Function<V, W>; valuesweights
- Function<V, W>; weightspublic final AbstractMean<MT,V,W> add(Iterable<V> values)
values
- V[]; the values to addpublic final AbstractMean<MT,V,W> add(V[] values)
values
- V[]; the values to addCopyright © 2018–2019 Delft University of Technology. All rights reserved.