Ejemplo n.º 1
0
        /// <summary>
        /// Returns the sampler for a specified rng, data type and distribution spec
        /// </summary>
        /// <param name="rng">The random stream</param>
        /// <param name="spec">The distribution specifier</param>
        /// <typeparam name="T">The sample point type</typeparam>
        public static ISampler <T> Sampler <T>(this MklRng rng, IDistributionSpec <T> spec)
            where T : unmanaged
        {
            var sampler = default(ISampler <T>);

            switch (spec.DistKind)
            {
            case DistKind.Uniform:
                sampler = rng.UniformSampler <T>(UniformSpec.From(spec));
                break;

            case DistKind.UniformBits:
                sampler = rng.UniformBitsSampler <T>(UniformBitsSpec.From(spec));
                break;

            case DistKind.Bernoulli:
                sampler = rng.BernoulliSampler <T>(BernoulliSpec.From(spec));
                break;

            case DistKind.Gaussian:
                sampler = rng.GaussianSampler <T>(GaussianSpec.From(spec));
                break;

            default:
                throw unsupported <T>();
            }

            return(sampler);
        }
Ejemplo n.º 2
0
Archivo: Sampler.x.cs Proyecto: 0xCM/z0
        /// <summary>
        /// Returns the sampler for a specified rng, data type and distribution spec
        /// </summary>
        /// <param name="rng">The random stream</param>
        /// <param name="spec">The distribution specifier</param>
        /// <typeparam name="T">The sample point type</typeparam>
        public static IRngSampler <T> Sampler <T>(this MklRng rng, IDistributionSpec <T> spec)
            where T : unmanaged
        {
            var sampler = default(IRngSampler <T>);

            switch (spec.DistKind)
            {
            case DistributionKind.Uniform:
                sampler = rng.UniformSampler <T>(Distributions.uniform(spec));
                break;

            case DistributionKind.UniformBits:
                sampler = rng.UniformBitsSampler <T>(Distributions.uniformbits(spec));
                break;

            case DistributionKind.Bernoulli:
                sampler = rng.BernoulliSampler <T>(Distributions.bernoulli(spec));
                break;

            case DistributionKind.Gaussian:
                sampler = rng.GaussianSampler <T>(Distributions.gaussian(spec));
                break;

            default:
                throw Unsupported.define <T>();
            }

            return(sampler);
        }
Ejemplo n.º 3
0
 public static GammaSpec <T> From <T>(IDistributionSpec <T> src)
     where T : unmanaged
 => (GammaSpec <T>)src;
Ejemplo n.º 4
0
 public static BinomialSpec <T> From(IDistributionSpec <T> src)
 => (BinomialSpec <T>)src;
Ejemplo n.º 5
0
 public static BernoulliSpec <T> From <T>(IDistributionSpec <T> src)
     where T : unmanaged
 => (BernoulliSpec <T>)src;
Ejemplo n.º 6
0
 public static UniformSpec <T> From <T>(IDistributionSpec <T> spec)
     where T : unmanaged
 => (UniformSpec <T>)spec;
Ejemplo n.º 7
0
 public static BetaSpec <T> From(IDistributionSpec <T> src)
 => (BetaSpec <T>)src;
Ejemplo n.º 8
0
 public static UniformBitsSpec <T> From <T>(IDistributionSpec <T> src)
     where T : unmanaged
 => (UniformBitsSpec <T>)src;