Package org.opentrafficsim.core.math
Class Draw
java.lang.Object
org.opentrafficsim.core.math.Draw
Utility to draw from a collection.
Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
-
Method Summary
Modifier and TypeMethodDescriptionstatic <E> Edraw(Collection<E> collection, StreamInterface stream) Returns a randomly drawn element using uniform weights.static <E> EdrawWeighted(Map<E, ? extends Double> map, StreamInterface stream) Returns a randomly drawn element using draw weights.
-
Method Details
-
drawWeighted
Returns a randomly drawn element using draw weights.- Type Parameters:
E- element type- Parameters:
map- map of elements and respective weightsstream- random number stream- Returns:
- randomly drawn element
-
draw
Returns a randomly drawn element using uniform weights.- Type Parameters:
E- element type- Parameters:
collection- collection of elementsstream- random number stream- Returns:
- randomly drawn element
-