Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Distributions/LogitNormalModel.cs @ 13067

Last change on this file since 13067 was 11851, checked in by gkronber, 10 years ago

#2283: solution reorganization

File size: 816 bytes
Line 
1using System;
2using System.Runtime.InteropServices;
3using HeuristicLab.Common;
4
5namespace HeuristicLab.Algorithms.Bandits.Models {
6  public class LogitNormalModel : IModel {
7
8    private readonly GaussianModel gaussian;
9
10    // this constructor assumes the variance is known
11    public LogitNormalModel() { gaussian = new GaussianModel(0, 1000, 1, 1); }
12
13
14
15    public double Sample(Random random) {
16      return 1.0 / (1 + Math.Exp(-gaussian.Sample(random)));
17    }
18
19    public void Update(double reward) {
20      gaussian.Update(Math.Log(reward / (1 - reward)));
21    }
22
23    public void Reset() {
24      gaussian.Reset();
25    }
26
27    public object Clone() {
28      return new LogitNormalModel();
29    }
30
31    public override string ToString() {
32      return string.Empty;
33    }
34  }
35}
Note: See TracBrowser for help on using the repository browser.