protected override Task <double> Frequency(double t, int n, int channel) { var isThisFeature = featureChooser.IsFeature(n, nameof(FeatureProbabilityModel.Frequency)); if (!isThisFeature) { return(Task.FromResult(pulseFrequency.Quiescent)); } var section = sectionsProvider.Section(n); var topFrequency = topFrequencyCache.GetOrAdd(section, CreateTopFrequency); var frequency = featureProvider.FeatureValue(t, n, pulseFrequency.Quiescent, topFrequency); return(Task.FromResult(frequency)); }
private double Wetness(double t, int n) { if (wetness == null) { return(0); } if (sections == null) { return(wetness.Maximum); } // rise in a sin^2 fashion from MinWetness to MaxWetness var section = sectionsProvider.Section(n); var maxForSection = maxWetnessForSectionCache.GetOrAdd(section, s => { var numSections = sectionsProvider.NumSections(); var progression = (double)s / Math.Max(1, numSections - 1); // <= 1 var max = randomizer.ProportionAlong(wetness.Variation, progression, wetness.Minimum, wetness.Maximum); return(max); }); double value; if (wetness.LinkToFeature) { var isThisFeature = featureChooser.IsFeature(n, nameof(FeatureProbabilityModel.Wetness)); value = isThisFeature ? featureProvider.FeatureValue(t, n, wetness.Minimum, maxForSection) : wetness.Minimum; } else { value = maxForSection; } return(value); }