Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3075_aifeynman_instances/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/Feynman/Feynman3.cs @ 17639

Last change on this file since 17639 was 17639, checked in by chaider, 4 years ago

#3075

  • Added rest of part I equations
  • Set Training/Test Partitions to 105
File size: 1.7 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Threading.Tasks;
6using HeuristicLab.Common;
7using HeuristicLab.Random;
8
9namespace HeuristicLab.Problems.Instances.DataAnalysis {
10  public class Feynman3 : FeynmanDescriptor{
11 public override string Name { get { return "Feynman I.6.2b f = exp(-((theta-theta1)/sigma)^2/2)/(sqrt(2*pi)*sigma)"; } }
12
13 protected override string TargetVariable { get { return "f"; } }
14    protected override string[] VariableNames { get { return new string[] { "sigma", "theta", "theta1", "f"}; } }
15    protected override string[] AllowedInputVariables { get { return new string[] { "sigma", "theta", "theta1" }; } }
16
17    public int Seed { get; private set; }
18
19    public Feynman3() : this((int)System.DateTime.Now.Ticks) { }
20
21    public Feynman3(int seed) {
22      Seed = seed;
23    }
24
25    protected override List<List<double>> GenerateValues() {
26      var rand = new MersenneTwister((uint)Seed);
27
28      var data = new List<List<double>>();
29      var sigma = ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 1, 3).ToList();
30      var theta = ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 1, 3).ToList();
31      var theta1 = ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 1, 3).ToList();
32
33      var f = new List<double>();
34
35      data.Add(sigma);
36      data.Add(theta);
37      data.Add(theta1);
38      data.Add(f);
39
40
41      for (var i = 0; i < theta.Count; i++) {
42        var res = Math.Exp(-(Math.Pow(theta[i] - theta1[i], 2) / sigma[i]) / 2) / (Math.Sqrt(2 * Math.PI) * sigma[i]);
43        f.Add(res);
44      }
45
46
47      return data;
48    }
49  }
50}
Note: See TracBrowser for help on using the repository browser.