using System; using System.Runtime.InteropServices; using HeuristicLab.Common; namespace HeuristicLab.Algorithms.Bandits.Models { public class LogitNormalModel : IModel { private readonly GaussianModel gaussian; // this constructor assumes the variance is known public LogitNormalModel() { gaussian = new GaussianModel(0, 1000, 1, 1); } public double Sample(Random random) { return 1.0 / (1 + Math.Exp(-gaussian.Sample(random))); } public void Update(double reward) { gaussian.Update(Math.Log(reward / (1 - reward))); } public void Reset() { gaussian.Reset(); } public object Clone() { return new LogitNormalModel(); } public override string ToString() { return string.Empty; } } }