Newer
Older
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
54
55
56
57
58
59
60
61
62
63
64
65
66
{
"cells": [
{
"cell_type": "code",
"execution_count": 9,
"outputs": [],
"source": [
"from ntrfc.timeseries.stationarity import stationarity\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 10,
"outputs": [],
"source": [
"def signalgen_abatingsine(amplitude, noiseamplitude, frequency, mean, abate, time):\n",
" resolution = 2048\n",
" step = (resolution * frequency ** -1) ** -1\n",
"\n",
" times = np.arange(0, time, step)\n",
" noise = np.random.normal(-1, 1, len(times)) * noiseamplitude\n",
"\n",
" values = amplitude * np.sin(frequency * (2 * np.pi) * times) + mean + np.e ** -(times * abate) + noise\n",
" return times, values"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 11,
"outputs": [],
"source": [
"test_amplitudes = 0.1\n",
"test_noiseamplitude = 0.01\n",
"test_frequencies = 6\n",
"test_times = 40\n",
"test_mean = -1\n",
"test_abate = 1\n",
"\n",
"\n",
"timesteps, values = signalgen_abatingsine(amplitude=test_amplitudes, noiseamplitude=test_noiseamplitude,\n",
" frequency=test_frequencies, mean=test_mean, time=test_times,\n",
" abate=test_abate)\n"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"outputs": [],
"source": [
"stationary_timestep = stationarity(timesteps, values)\n",
"\n",
"well_computed_stationarity_limit = -np.log(0.05) / abate\n",
"well_computed_stationary_time = timesteps[-1] - well_computed_stationarity_limit\n",
"stationary_time = timesteps[-1] - stationary_timestep\n"
],
"metadata": {
"collapsed": false,
"pycharm": {
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
}
}
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"plt.figure()\n",
"plt.plot(timesteps, values)\n",
"plt.axvline(stationary_timestep, color=\"green\")\n",
"plt.show()\n"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 0
}