24 package org.lightjason.agentspeak.action.builtin.math.statistic;
26 import org.apache.commons.math3.distribution.AbstractRealDistribution;
35 import javax.annotation.Nonnegative;
36 import javax.annotation.Nonnull;
37 import java.util.Arrays;
38 import java.util.Collections;
39 import java.util.List;
40 import java.util.stream.Collectors;
41 import java.util.stream.Stream;
78 @Nonnull
final List<ITerm> p_argument, @Nonnull
final List<ITerm> p_return )
80 final List<ITerm> l_arguments =
CCommon.
flatten( p_argument ).collect( Collectors.toList() );
83 l_arguments.size() < 2
85 : l_arguments.stream()
87 .map(
ITerm::<Number>raw )
89 .mapToInt( Number::intValue )
90 .mapToObj( i ->
CRandomSample.
samples( l_arguments.get( 0 ).<AbstractRealDistribution>raw(), i, p_parallel ) )
91 .forEach( p_return::add );
105 private static ITerm samples( @Nonnull
final AbstractRealDistribution p_distribution,
final int p_size,
final boolean p_parallel )
110 final List<Double> l_list = Arrays.stream( p_distribution.sample( p_size ) ).boxed().collect( Collectors.toList() );
111 return CRawTerm.
from( p_parallel ? Collections.synchronizedList( l_list ) : l_list );
base class of build-in actions for setting name by package/classname (without prefix character) ...
static< N > IFuzzyValue< N > from( @Nonnull final N p_value)
factory
common structure for execution definition
execution context with local data
static Stream< ITerm > flatten( @Nonnull final Collection<? extends ITerm > p_terms)
flat term-in-term collection into a straight term list
result for an immutable fuzzy value
static final long serialVersionUID
serial id
static< N > CRawTerm< N > from(final N p_value)
factory for a raw term
create a (set) of random values.
static ITerm samples( @Nonnull final AbstractRealDistribution p_distribution, final int p_size, final boolean p_parallel)
creates the sample structure
final IFuzzyValue< Boolean > execute(final boolean p_parallel, @Nonnull final IContext p_context, @Nonnull final List< ITerm > p_argument, @Nonnull final List< ITerm > p_return)
defines a plan-body operation
final int minimalArgumentNumber()
minimum number of arguments
term structure for simple datatypes