"

DistributionExtensions.

SelectMany<TSource, TResult>(IDistribution<TSource>, Func<TSource, IDistribution<TResult>>) Method

Summary

Transforms a distribution by mapping values using the selector provided to produce a new distribution, which is then sampled from. This method implements the "bind" operator from functional programming principles.

Syntax

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

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.
TResultThe generic type of the output distribution.

Parameters

NameTypeDescription
distributionIDistribution<TSource>The distribution to be transformed.
selectorFunc<TSource, IDistribution<TResult>>The projection to be applied to values from the distribution.

Return Value

TypeDescription
IDistribution<TResult>