Documentation > Explore > Samplings
In the following example, 100 values are generated at random, uniformly distributed between 0 and 20.
For more information on the @code{map} function, or other transformation functions, see the Language section.
Sample within a uniform distribution 🔗
Samplings can be performed at random within a domain following a uniform ditribution, via theUniformDistribution(maximum)
command.
This task generates values uniformly distributed between zero and the maximum argument:
In the following example, 100 values are generated at random, uniformly distributed between 0 and 20.
val my_input = Val[Double]
val my_model = EmptyTask() set( (inputs, outputs) += my_input)
val exploration =
DirectSampling(
evaluation = my_model hook display,
sampling= my_input in UniformDistribution[Double](max=20).take(100)
)
exploration
Sample within a skewed uniform distribution 🔗
Custom domains can be defined using transformations on the uniform distribution. For instance in this next example, 100 values uniformly distributed between 0 and 20 are still generated at random, however, each one is then shifted by -10 through themap
function.
Thus, the sampling will be comprised of 100 values uniformly distributed between -10 and 10.
val my_input = Val[Double]
val my_model = EmptyTask() set( (inputs, outputs) += my_input)
val exploration =
DirectSampling(
evaluation = my_model hook display,
sampling= my_input in UniformDistribution[Double](max=20).take(100).map(x => x -10)
)
exploration
For more information on the @code{map} function, or other transformation functions, see the Language section.