/// <summary>
        /// Samples a value defined for the parameter.
        /// </summary>
        /// <param name="sampler"></param>
        /// <returns></returns>
        public double SampleValue(IParameterSampler sampler)
        {
            // sample random parameter index.
            var index = (int)sampler.Sample(m_minIndex, m_maxIndex, m_parameterType);

            // return the values of the index.
            return(m_parameters[index]);
        }
        /// <summary>
        /// Logarithmic scale. For ranges with a large difference in numerical scale, like min: 0.0001 and max: 1.0.
        /// </summary>
        /// <param name="min"></param>
        /// <param name="max"></param>
        /// <param name="sampler"></param>
        /// <returns></returns>
        public double Transform(double min, double max, IParameterSampler sampler)
        {
            if (min <= 0 || max <= 0)
            {
                throw new ArgumentException($"logarithmic scale requires min: {min} and max: {max} to be larger than zero");
            }
            var a = Math.Log10(min);
            var b = Math.Log10(max);

            var r = sampler.Sample(a, b);

            return(Math.Pow(10, r));
        }
        /// <summary>
        /// ExponentialAverage scale. For ranges close to one, like min: 0.9 and max: 0.999.
        /// Note that the min and max values must be smaller than 1 for this transform.
        /// </summary>
        /// <param name="min"></param>
        /// <param name="max"></param>
        /// <param name="sampler"></param>
        /// <param name="parameterType">Selects the type of parameter. Should the parameter be sampled as discrete values, or as continous values.</param>
        /// <returns></returns>
        public double Transform(double min, double max, ParameterType parameterType, IParameterSampler sampler)
        {
            if (min >= 1 || max >= 1)
            {
                throw new ArgumentException($"ExponentialAverage scale requires min: {min} and max: {max} to be smaller than one");
            }
            var a = Math.Log10(1 - max);
            var b = Math.Log10(1 - min);

            var r = sampler.Sample(a, b, parameterType);

            return(1.0 - Math.Pow(10, r));
        }
示例#4
0
 /// <summary>
 /// Linear scale. For ranges with a small difference in numerical scale, like min: 64 and max: 256.
 /// Returns the samplers value directly.
 /// </summary>
 /// <param name="min"></param>
 /// <param name="max"></param>
 /// <param name="sampler"></param>
 /// <returns></returns>
 public double Transform(double min, double max, IParameterSampler sampler)
 {
     return(sampler.Sample(min, max));
 }
 /// <summary>
 /// Linear scale. For ranges with a small difference in numerical scale, like min: 64 and max: 256.
 /// Returns the samplers value directly.
 /// </summary>
 /// <param name="min"></param>
 /// <param name="max"></param>
 /// <param name="sampler"></param>
 /// <param name="parameterType">Selects the type of parameter. Should the parameter be sampled as discrete values, or as continous values.</param>
 /// <returns></returns>
 public double Transform(double min, double max, ParameterType parameterType, IParameterSampler sampler)
 {
     return(sampler.Sample(min, max, parameterType));
 }