Free cookie consent management tool by TermsFeed Policy Generator

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

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

#3106 updated implementation based on the reply by Moscato

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