Free cookie consent management tool by TermsFeed Policy Generator

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

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

#3075 Added first part of feynman equations as instances

File size: 1.8 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 Feynman2 : FeynmanDescriptor{
11 public override string Name { get { return "Feynman I.6.2a f = exp(-(theta/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", "f"}; } }
15    protected override string[] AllowedInputVariables { get { return new string[] { "sigma", "theta" }; } }
16
17    protected override int TrainingPartitionStart { get { return 0; } }
18    protected override int TrainingPartitionEnd { get { return 80; } }
19    protected override int TestPartitionStart { get { return 80; } }
20    protected override int TestPartitionEnd { get { return 100; } }
21
22    public int Seed { get; private set; }
23
24    public Feynman2() : this((int)System.DateTime.Now.Ticks) { }
25
26    public Feynman2(int seed) {
27      Seed = seed;
28    }
29
30    protected override List<List<double>> GenerateValues() {
31      var rand = new MersenneTwister((uint)Seed);
32
33      var data = new List<List<double>>();
34      var theta = ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 1, 3).ToList();
35      var sigma = ValueGenerator.GenerateUniformDistributedValues(rand.Next(), TestPartitionEnd, 1, 3).ToList();
36
37      var f = new List<double>();
38
39      data.Add(theta);
40      data.Add(sigma);
41      data.Add(f);
42
43
44      for (var i = 0; i < theta.Count; i++) {
45        var res = Math.Exp(-Math.Pow(theta[i] / sigma[i], 2) / 2) / (Math.Sqrt(2 * Math.PI) * sigma[i]);
46        f.Add(res);
47      }
48
49
50      return data;
51    }
52  }
53}
Note: See TracBrowser for help on using the repository browser.