Changeset 12876 for branches/HeuristicLab.Problems.GrammaticalOptimization-gkr/HeuristicLab.Problems.Bandits
- Timestamp:
- 08/17/15 19:13:19 (9 years ago)
- Location:
- branches/HeuristicLab.Problems.GrammaticalOptimization-gkr/HeuristicLab.Problems.Bandits
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.GrammaticalOptimization-gkr/HeuristicLab.Problems.Bandits/GaussianBandit.cs
r11849 r12876 12 12 public int OptimalExpectedRewardArm { get; private set; } 13 13 public int OptimalMaximalRewardArm { get; private set; } 14 14 public double MaxReward { get; private set; } 15 public double MinReward { get; private set; } 15 16 private readonly Random random; 16 17 private readonly double[] exp; 17 18 private readonly double[] stdDev; 18 public GaussianBandit(Random random, int nArms) { 19 public GaussianBandit(Random random, int nArms, double minReward = double.NegativeInfinity, double maxReward = double.PositiveInfinity) { 20 this.MaxReward = maxReward; 21 this.MinReward = minReward; 19 22 this.random = random; 20 23 this.NumArms = nArms; … … 31 34 OptimalExpectedRewardArm = i; 32 35 } 33 var q = alglib.invnormaldistribution(0.99 ) * stdDev[i] + exp[i];36 var q = alglib.invnormaldistribution(0.999) * stdDev[i] + exp[i]; 34 37 if (q > bestQ) { 35 38 bestQ = q; … … 39 42 } 40 43 41 // pulling an arm results in a truncatednormally distributed reward42 // with mean expReward[i] and std.dev 0.144 // pulling an arm results in a normally distributed reward 45 // with mean expReward[i] and std.dev 43 46 public double Pull(int arm) { 44 var z = Rand.RandNormal(random); 45 var x = z * stdDev[arm] + exp[arm]; 47 double x; 48 do { 49 var z = Rand.RandNormal(random); 50 x = z * stdDev[arm] + exp[arm]; 51 } while (x <= MinReward || x > MaxReward); 46 52 return x; 47 53 } -
branches/HeuristicLab.Problems.GrammaticalOptimization-gkr/HeuristicLab.Problems.Bandits/HeuristicLab.Problems.Bandits.csproj
r11981 r12876 41 41 <Compile Include="BanditHelper.cs" /> 42 42 <Compile Include="BernoulliBandit.cs" /> 43 <Compile Include="ParetoBandit.cs" /> 43 44 <Compile Include="GaussianBandit.cs" /> 44 45 <Compile Include="GaussianMixtureBandit.cs" /> -
branches/HeuristicLab.Problems.GrammaticalOptimization-gkr/HeuristicLab.Problems.Bandits/IBandit.cs
r11849 r12876 12 12 int OptimalMaximalRewardArm { get; } // arm which is optimal for optimization of maximal reward 13 13 14 double Pull(int arm); // pulling an arm returns a re gret14 double Pull(int arm); // pulling an arm returns a reward 15 15 } 16 16 }
Note: See TracChangeset
for help on using the changeset viewer.