Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3106_AnalyticContinuedFractionsRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/ContinuedFractionRegression/ContinuedFraction.cs @ 17971

Last change on this file since 17971 was 17971, checked in by gkronber, 3 years ago

#3106: first implementation of the algorithm as described in the paper

File size: 880 bytes
Line 
1using HeuristicLab.Core;
2using HeuristicLab.Problems.DataAnalysis;
3
4namespace HeuristicLab.Algorithms.DataAnalysis.ContinuedFractionRegression {
5  public class ContinuedFraction {
6    internal bool[] vars;
7    internal Term[] h;
8
9    public ContinuedFraction() { }
10    public ContinuedFraction(int nVars, int depth, IRandom rand) {
11      this.vars = new bool[nVars];
12      for (int i = 0; i < nVars; i++) vars[i] = rand.NextDouble() < 0.5;
13
14      this.h = new Term[depth * 2 + 1];
15      for (int i = 0; i < h.Length; i++) {
16        h[i] = new Term();
17        var hi = h[i];
18        hi.vars = (bool[])vars.Clone();
19        hi.coef = new double[nVars];
20        for (int vi = 0; vi < nVars; vi++) {
21          if (hi.vars[vi])
22            hi.coef[vi] = rand.NextDouble() * 6 - 3;
23        }
24        hi.beta = rand.NextDouble() * 6 - 3;
25      }
26    }
27  }
28}
Note: See TracBrowser for help on using the repository browser.