Rev | Line | |
---|
[11744] | 1 | using System;
|
---|
| 2 | using System.Runtime.InteropServices;
|
---|
| 3 | using HeuristicLab.Common;
|
---|
| 4 |
|
---|
| 5 | namespace 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 |
|
---|
[11851] | 15 | public double Sample(Random random) {
|
---|
| 16 | return 1.0 / (1 + Math.Exp(-gaussian.Sample(random)));
|
---|
[11744] | 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.