SelectMany<TSource, TIntermediate, TResult>(IDistribution<TSource>, Func<TSource, IDistribution<TIntermediate>>, Func<TSource, TIntermediate, TResult>) Method
Transforms a distribution by mapping values using the selector provided to produce a new distribution, which is then sampled from.

Syntax

public static IDistribution<TResult> SelectMany<TSource, TIntermediate, TResult>(this IDistribution<TSource> distribution, Func<TSource, IDistribution<TIntermediate>> selector, Func<TSource, TIntermediate, TResult> resultSelector)

Examples

This method enables use of LINQ query syntax over IDistribution<TResult>. For example:
IDistribution<PointF> unitSquarePointDistribution =
    from x in Uniform.NewInclusive(0.0, 1.0)
    from y in Uniform.NewInclusive(0.0, 1.0)
    select new System.Drawing.PointF(x, y);

Remarks

When using
TrySample
on the result, if the distribution fails then the selector is not applied.

Type Parameters

NameDescription
TSourceThe generic type of the input distribution.
TIntermediateThe generic type of the intermediate distribution.
TResultThe generic type of the output distribution.

Parameters

NameTypeDescription
distributionIDistribution<TSource>The distribution to be transformed.
selectorFunc<TSource, IDistribution<TIntermediate>>The projection to be applied to values from the distribution to produce an intermediate distribution.
resultSelectorFunc<TSource, TIntermediate, TResult>The projection to be applied to values from both distributions.

Return Value

TypeDescription
IDistribution<TResult>