This repository was archived by the owner on May 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMackeyGlassGenerator.cs
More file actions
53 lines (46 loc) · 1.55 KB
/
MackeyGlassGenerator.cs
File metadata and controls
53 lines (46 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.Collections.Generic;
using System.Linq;
namespace RCNet.Neural.Data.Generators
{
/// <summary>
/// Implements the Mackey-Glass generator.
/// </summary>
[Serializable]
public class MackeyGlassGenerator : IGenerator
{
//Constants
private static readonly double[] IniValues = { 0.9697, 0.9699, 0.9794, 1.0003, 1.0319, 1.0703, 1.1076, 1.1352, 1.1485, 1.1482, 1.1383, 1.1234, 1.1072, 1.0928, 1.0820, 1.0756, 1.0739, 1.0759 };
//Attributes
private List<double> _lastValues;
private readonly MackeyGlassGeneratorSettings _cfg;
//Constructor
/// <summary>
/// Creates an initialized instance.
/// </summary>
/// <param name="cfg">The configuration.</param>
public MackeyGlassGenerator(MackeyGlassGeneratorSettings cfg)
{
_cfg = (MackeyGlassGeneratorSettings)cfg.DeepClone();
Reset();
return;
}
//Methods
/// <inheritdoc />
public void Reset()
{
_lastValues = IniValues.ToList();
return;
}
/// <inheritdoc />
public double Next()
{
double refMGV = _lastValues[_lastValues.Count - _cfg.Tau];
double lastMGV = _lastValues.Last();
double nextMGV = lastMGV - _cfg.B * lastMGV + _cfg.C * refMGV / (1 + Math.Pow(refMGV, 10));
_lastValues.RemoveAt(0);
_lastValues.Add(nextMGV);
return nextMGV;
}
}//MackeyGlassGenerator
}//Namespace