Transforms a distribution by mapping values using the selector provided to produce a new distribution, which is then sampled from.
- Namespace
- RandN
.Extensions - Containing Type
- Distribution
Extensions
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
Name | Description |
---|---|
TSource | The generic type of the input distribution. |
TIntermediate | The generic type of the intermediate distribution. |
TResult | The generic type of the output distribution. |
Parameters
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
distribution | IDistributionThe distribution to be transformed. | selector | Func | The projection to be applied to values from the distribution to produce an intermediate distribution. | resultSelector | Func | The projection to be applied to values from both distributions. | |
Return Value
Type | Description |
---|---|
IDistribution |