arXiv:1608.02166v3 [cs.NA] 16 Aug 2016
Analysis of time series and signals using the
Square Wave Method
Osvaldo Skliar∗
Ricardo E. Monge†
Sherry Gapper‡
November 12, 2021
Abstract
The Square Wave Method (SWM), previously introduced for the analysis of signals and images, is presented here as a mathematical tool suitable for the analysis of time series and signals. To show the potential that
the SWM has to analyze many different types of time series, the results
of the analysis of a time series composed of a sequence of 10,000 numerical values are presented here. These values were generated by using the
Mathematical Random Number Generator (MRNG).
Keywords: time series analysis; signal analysis; signals with abrupt changes;
square wave method; square wave transform
Mathematics Subject Classification: 62M10, 94A12, 65F99
∗ Escuela de Informática, Universidad Nacional, Costa Rica. E-mail:
[email protected];
[email protected]
† Escuela de Ciencias de la Computación e Informática, Universidad de Costa Rica, Costa
Rica. E-mail:
[email protected]
‡ Universidad Nacional, Costa Rica. E-mail:
[email protected]
1
1
Introduction
The objective of this article is to address the analysis of time series using a
method known as the Square Wave Method (SWM), which was introduced previously for the analysis of signals and images [1], [2], [3].
By using the SWM, consideration is given to the analysis of time series,
for which the time interval between any two consecutive values in the series
analyzed remains constant.
If a given time series can be considered to be an adequate representation
of a signal during a certain time lapse between an initial instant t0 and a final
instant tf , then the analysis of that series, using the SWM, is also an analysis
of that signal, within that period of time.
The results obtained after analyzing time series with the SWM are expressed
in the frequency domain in a clear, precise and concise way by using a previously
introduced mathematical tool, known as the Square Wave Transform (SWT) [1].
Each time series is composed of a sequence of values. One significant characteristic of the SWM is that it takes into account the order in which those
values appear. The analysis process of a time series, conducted with the SWM,
leads to certain basic components, specific trains of square waves, from which
the time series analyzed can be entirely reconstructed. That is precisely why if
a time series may be considered to be a adequate representation of a signal, the
analysis of that series using the SWM can also be a valid analysis of that signal.
That significant characteristic of the SWM makes it quite different from
other valuable methods, statistical methods in particular, used for the analysis
of time series [4].
The SWM is reviewed in section 2 to show the relevance of this method as
a mathematical tool for the analysis of time series. This information has been
included here to provide a solid basis for anyone who has not read previous
articles on the SWM.
2
An example of the analysis of a time series
using the SWM
The procedure to be used to analyze a time series using the SWM is presented
in this section.
Suppose that every quarter of a second (0.25 s) a measurement is made of
the difference in the electric potential between two points (point 1 and point
2). To simplify the explanation of the procedure used, suppose that the values
measured, expressed in millivolts (mV), have been rounded off (for didactic
purposes) to whole values. (Later on, the values will no longer be rounded off.)
Let us admit that the sequence of values measured in millivolts, during 2 s,
is the following:
84, −152, 63, 98, −35, 0, 145, −14
Of course, the positive values in this sequence imply that in each case the
2
electric potential of point 1 is greater than that of point 2. Likewise, the negative
values in the above sequence imply that in each case the electric potential of
point 1 is less than that of point 2. The value of 0 in that sequence of values
implies that, under the given precision, the values of the electric potentials of
points 1 and 2 are equal.
The values of this time series are shown in figure 1.
Figure 1: Graphic representation of the time series, that is, of the sequence of
measured values of differences in electric potential, mentioned above. Note that
the time interval between the two consecutive measurements is equal to 0.25 s.
According to the SWM, each of the measured values in the time series considered can be approximated very precisely by adding up 8 values. Each of these
8 values is located in a corresponding train of square waves.
Reference is made here to the 8 added values and to the 8 corresponding
trains of square waves because in this case the time series considered is made
up of 8 measured values. If the sequence were composed of 1,000 measured
values, it would be necessary to add up the 1,000 values situated in the 1,000
corresponding trains of square waves, to approximate each of those measured
values. In general, if that time series is made up of n values, such that n =
1, 2, 3, . . ., then to approximate each of those values, the n values situated in n
corresponding trains of square waves must be added up.
An explanation is provided below of how to discover 1) what values must be
added up to approximate each measured value; 2) which trains of square waves
are being referred to; and 3) where the values that must be summed up are
located in those trains of square waves.
Consider the case for which n = 8, specified in figure 1. Figure 2 illustrates
that case.
3
∆t = 2 s
C1
C1
C1
C1
C1
C1
C1
C1
C2
C2
C2
C2
C2
C2
C2 −C2
C3
C3
C3
C3
C3
C3 −C3 −C3
C4
C4
C4
C4
C4 −C4 −C4 −C4
C5
C5
C5
C5 −C5 −C5 −C5 −C5
C6
C6
C6 −C6 −C6 −C6 C6
C7
C7 −C7 −C7 C7
C6
C7 −C7 −C7
C8 −C8 C8 −C8 C8 −C8 C8 −C8
Figure 2: How to apply the SWM to the time series made up of the sequence
of the 8 numerical values specified; see indications below.
4
999
999
999
Note that figure 2 is composed of 8 rows and 8 columns. It may be considered
to be an 8 by 8 matrix.
Look first at the eighth row, corresponding to the eighth train of square
waves S8 to be analyzed. In that row, the sequence C8 −C 8 corresponds to
one square wave in S8 ; C8 corresponds to the first semi-wave of that square
wave, and −C8 to the second square wave. Which one of those semi-waves is
positive and which is negative depends on the value to be computed (as specified
below) for C8 . If C8 is positive, then the first semi-wave will be positive, and
the second will be negative. If, however, C8 is negative, then the first semi-wave
will be negative, and the second will be positive.
Note that in the last row, that of S8 , there are exactly 4 square waves; that is,
those 4 square waves fit in 2 s (the total duration of the interval ∆t during which
time the values of the time series analyzed were measured). The frequency f8
corresponding to that train of square waves S8 is equal to the number of square
waves that fit in the time unit 1 s; therefore, f8 = 2 Hz.
The wavelength of the next to the last train of square waves S7 (corresponding to the next to the last line in figure 2), is twice the wavelength of the train of
square waves S8 . The wavelength of the second to the last train of square waves
S6 is triple the wavelength of S8 , and so on successively. Hence, the wavelength
S1 , the train of square waves in the first row in figure 2, is 8 times greater than
the wavelength of S8 .
Given that the wavelength in S7 is twice that of S8 , the frequency f7 corresponding to S7 is half that of f8 : f7 = 21 f8 . In figure 2, it can be seen that one
square wave in S7 fits exactly in the unit of time 1 s; one square wave in S7 is
999
999
999
999
999
999
999
999
999
999
999
999
999
999
represented in figure 2 as: C7 C7 − C7 − C7 .
To understand the formalism used, one may carefully verify at least some
of the above results. Thus, for example, consider the following equation: f5 =
1
1
1
4 f8 = 4 · 2 Hz = 2 Hz. For the train of square waves S5 , one square wave can be
represented in figure 2 as: C5 C5 C5 C5 −C 5 −C 5 −C 5 −C 5 . For S5 ,
exactly one square wave fits in the entire lapse in ∆t = 2 s, as is clearly shown
in figure 2; and exactly one semi-wave in S5 fits in the unit of time 1 s. So by
definition of the notion of frequency, the number of waves per unit of time, the
1
frequency f5 corresponding to S5 is: f5 = 12s = 21s = 21 Hz.
In the example discussed, 4 values were measured per second. In other words,
for the sampling frequency fs , this equation is valid: fs = 4 Hz; the following
relation between f8 and fs is also valid: f8 = 21 fs .
The results obtained for the frequencies fi , where i = 1, 2, . . . , 8, corresponding to the different trains of square waves Si are:
f1 =
f2 =
f3 =
f4 =
f5 =
f6 =
f7 =
f8 =
2
1
Hz= Hz
8
4
2
Hz
7
1
2
Hz= Hz
6
3
2
Hz
5
1
2
Hz= Hz
4
2
2
Hz
3
2
Hz = 1 Hz
2
2
Hz = 2 Hz
1
How to compute the values of the 8 coefficients C1 , C2 , C3 , C4 , C5 , C6 , C7 ,
and C8 , displayed in figure 2 will be specified below.
In this example, the interval ∆t = 2 s was divided into 8 equal subintervals
because the time series analyzed is made up of exactly 8 equal values. If that
time series were composed of 50, 000 values, then the interval ∆t would be divided into 50,000 equal subintervals. In general, if the time series to be analyzed
is made up of n values, where n = 1, 2, 3, . . ., then ∆t is divided into n equal
subintervals.
First, look at the left column in figure 2, and add up the elements in that
column, following the order indicated by the vertical arrow pointing down (at
the right of the figure) and the result is made equal to the first value, 84 mV, of
that time series. Hence, the following equation is obtained:
C1 + C2 + C3 + C4 + C5 + C6 + C7 + C8 = 84 mV
5
Note that C1 , C2 , C3 , C4 , C5 , C6 , C7 , and C8 are respectively the values of
the trains of square waves S1 , S2 , S3 , S4 , S5 , S6 , S7 , and S8 , at the midpoint
of the first subinterval of ∆t.
Then, look at the second column in figure 2, and add up the elements in
that column making the result equal to the second value, −152 mV, in that
time series. Thus, the following equation is obtained:
C1 + C2 + C3 + C4 + C5 + C6 + C7 − C8 = −152 mV
Observe that C1 , C2 , C3 , C4 , C5 , C6 , C7 , and −C8 are respectively the
values of the trains of square waves S1 , S2 , S3 , S4 , S5 , S6 , S7 , and S8 , at the
midpoint of the second subinterval of ∆t.
Now look at the third column in figure 2, and add up the elements in that
column, making the result equal to the third value, 63 mV, in that time series.
The following equation is obtained:
C1 + C2 + C3 + C4 + C5 + C6 − C7 + C8 = 63 mV
Note that C1 , C2 , C3 , C4 , C5 , C6 , −C7 , and C8 are respectively the values
of the trains of square waves S1 , S2 , S3 , S4 , S5 , S6 , S7 , and S8 , at the midpoint
of the third subinterval of ∆t.
The fourth, fifth, sixth and seventh equations are obtained using the same
type of procedure.
Finally, that procedure is applied to the eighth column in 2, and the following equation is obtained:
C1 − C2 − C3 − C4 − C5 + C6 − C7 − C8 = −14 mV
Observe that C1 , −C2 , −C3 , −C4 , −C5 , C6 , −C7 , and −C8 are respectively
the values of the trains of square waves for S1 , S2 , S3 , S4 , S5 , S6 , S7 , and S8 ,
at the midpoint of the eighth subinterval of ∆t.
The following system of 8 linear algebraic equations was obtained as specified
above.
C1 + C2 + C3 + C4 + C5 + C6 + C7 + C8 =
84 mV
C1 + C2 + C3 + C4 + C5 + C6 + C7 − C8 = −152 mV
C1 + C2 + C3 + C4 + C5 + C6 − C7 + C8 =
63 mV
C1 + C2 + C3 + C4 + C5 − C6 − C7 − C8 =
98 mV
(1)
C1 + C2 + C3 + C4 − C5 − C6 + C7 + C8 =
−35 mV
C1 + C2 + C3 − C4 − C5 − C6 + C7 − C8 =
0 mV
C1 + C2 − C3 − C4 − C5 + C6 − C7 + C8 =
145 mV
C −C −C −C −C +C −C −C =
−14 mV
1
2
3
4
5
6
7
8
The above system of 8 linear algebraic equations (1) has 8 unknowns: C1 ,
C2 , C3 , C4 , C5 , C6 , C7 , and C8 , which are precisely the 8 coefficients whose
values must be computed.
6
Once that system of equations (1) has been solved, the values for the coefficients are:
C1 =
170.5 mV
C5 =
195.0 mV
C2 =
−38.5 mV
C6 = −135.5 mV
C3 =
C4 =
−100.5 mV
−135.5 mV
C7 =
C8 =
10.5 mV
118.0 mV
If in each member on the left side of the system of equations (1), the coefficients C1 , C2 , C3 , C4 , C5 , C6 , C7 , and C8 are replaced by the values computed
for them, and if the resulting 8 algebraic sums are completed, the following
system of 8 equations is obtained:
(170.5 − 38.5 − 100.5 − 135.5 + 195 − 135.5 + 10.5 + 118) mV =
84 mV
(170.5 − 38.5 − 100.5 − 135.5 + 195 − 135.5 + 10.5 − 118) mV = −152 mV
(170.5 − 38.5 − 100.5 − 135.5 + 195 − 135.5 − 10.5 + 118) mV =
63 mV
(170.5 − 38.5 − 100.5 − 135.5 + 195 + 135.5 − 10.5 − 118) mV =
98 mV
(170.5 − 38.5 − 100.5 − 135.5 − 195 + 135.5 + 10.5 + 118) mV =
−35 mV
145 mV
−14 mV
(170.5 − 38.5 − 100.5 + 135.5 − 195 + 135.5 + 10.5 − 118) mV =
(2)
0 mV
(170.5 − 38.5 + 100.5 + 135.5 − 195 − 135.5 − 10.5 + 118) mV =
(170.5 + 38.5 + 100.5 + 135.5 − 195 − 135.5 − 10.5 − 118) mV =
Note that the members on the right of (2) coincide exactly with the members
on the right of (1).
In figure 3 the parts of the trains of square waves S1 , S2 , S3 , S4 , S5 , S6 , S7 ,
S8 corresponding to interval ∆t have been displayed.
mV
S1 (t)
200
100
0
1
2
-100
-200
(a) S1 (t).
7
t(s)
mV
S1 (t)
200
100
0
1
2
t(s)
2
t(s)
-100
-200
(b) S2 (t).
mV
S3 (t)
200
100
0
1
-100
-200
(c) S3 (t).
8
mV
S4 (t)
200
100
0
1
2
t(s)
2
t(s)
-100
-200
(d) S4 (t).
mV
S5 (t)
200
100
0
1
-100
-200
(e) S5 (t).
9
mV
S6 (t)
200
100
0
1
2
t(s)
2
t(s)
-100
-200
(f) S6 (t).
mV
S7 (t)
200
100
0
1
-100
-200
(g) S7 (t).
10
mV
S8 (t)
200
100
0
1
2
t(s)
-100
-200
(h) S8 (t).
Figure 3: Trains of square waves S1 , S2 , S3 , . . . , and S8
For each of the 8 equal subintervals of ∆t, the algebraic sum of the values
highlighted in those trains of square waves must be computed. The algebraic
sum corresponding to the i-th subinterval (i = 1, 2, 3, . . . , 8) must be equal to
the i-th value of the time series considered.
In general, this approach can be applied to analyze any time series composed
of n measured values, such that n = 1, 2, 3, . . ., during a specific time interval
∆t expressed in seconds. It is accepted that the lapse between two consecutive
values in the time series analyzed will remain constant.
The frequency of the measurement of values in the time series (or the sampling frequency fs ) is the number of values measured per second (the time unit).
Therefore, the number n of measured values in a time interval ∆t can be expressed as:
n = fs · ∆t.
999
999
999
If the time series is composed of n values, the interval ∆t must be divided
into n subintervals of equal duration.
To analyze that time series with the SWM, it is essential to construct an
n × n-matrix like that of figure 2.
The last row in that matrix corresponds to the n-th train of square waves
Sn of the n trains of square waves to be considered in this particular case.
Each square wave in Sn can be symbolized as Cn −C n , occupying 2 subintervals of the n equal subintervals into which ∆t was divided. Thus, the number
of square waves in Sn per time unit (fn ) can be expressed as follows:
1 n
·
2 ∆t
The next to the last row of this n × n-matrix is that of the train of square
waves Sn−1 ; each square wave is represented as Cn−1 Cn−1 −C n−1 −C n−1 .
11
999
999
999
999
999
fn =
999
999
999
999
999
999
999
It can be seen that the length of each of the square waves composing Sn−1 is
twice that of the wave of each square wave composing Sn . Hence, the frequency
fn−1 corresponding to Sn−1 is equal to half of frequency fn corresponding to
Sn :
1
fn−1 = · fn
2
The second to the last row in this n × n-matrix corresponds to the train
of square waves Sn−2 . Each square wave in Sn−2 can be represented as Cn−2
Cn−2 Cn−2 −C n−2 −C n−2 −C n−2 . It can be observed that the length of
each of the square waves composing Sn−2 is three times that of the wave of each
square wave composing Sn . Thus, the frequency fn−2 corresponding to Sn−2 is
equal to a third of the frequency fn corresponding to Sn :
fn−2 =
1
· fn
3
In general, the frequency fi corresponding to the i-th train of square waves
Si will be expressed as follows:
1
1 n
1
n
1
fi = fn−(n−i) =
· fn =
· ·
=
·
(3)
n−i+1
n − i + 1 2 ∆t
2∆t n − i + 1
The values of the coefficients C1 , C2 , . . . , Cn are computed with a procedure
like that used to compute C1 , C2 , . . . , C8 , in the example analyzed of a time
series composed of a sequence of 8 values.
To begin with, the algebraic sum of all the elements making up the first
column of the n × n-matrix is made equal to the first value of the time series to
be analyzed.
Next, the algebraic sum of all the elements composing the second column
of the n × n-matrix is made equal to the second value of the time series to be
analyzed.
And so on up to the algebraic sum of all the elements of the n-th column of
the n × n-matrix, which is made equal to the last value (n-th value) of the time
series to be analyzed.
In this way, a system of n linear algebraic equations is obtained. The coefficients C1 , C2 , . . . , Cn , which are the unknowns of that system of equations, can
be computed.
An algorithm to make it easier to determine the system of linear algebraic
equations will be described in section 3. This system of equations must be solved
whenever the SWM is used to analyze a time series.
Suppose that the SWM is being used to analyze a time series made up of
a sequence of n measured values of a signal depending on time. As explained
above, each train of square waves Si , for i = 1, 2, . . . , n, corresponding to that
analysis, will be characterized by the value of a frequency fi and the value of a
coefficient Ci that can be computed using the procedures described above. Thus
the result of the analysis can be expressed by a sequence of n dyads. The first
element of the first of those dyads is the value of f1 , and the second element of
12
the first dyad is C1 . The first element of the second dyad is the value of f2 , and
the second element of that second dyad is C2 , and so on, successively; hence,
the first element of the n-th dyad is the value of fn , and the second element of
that dyad is Cn .
Thus, for example, the 8 dyads that make it possible to express the result of
the analysis carried out with the SWM of the sequence of 8 values represented
in figure 1 are:
(f1 ; C1 ) = (0.250000; 170.500000)
(f3 ; C3 ) = (0.333333; −100.500000)
(f2 ; C2 ) = (0.285714; −38.500000)
(f4 ; C4 ) = (0.400000; −135.500000)
(f5 ; C5 ) = (0.500000; 195.000000)
(f6 ; C6 ) = (0.666667; −135.500000)
(f8 ; C8 ) = (2.000000; 118.000000)
(f7 ; C7 ) = (1.000000; 10.500000)
A mathematical tool (the Square Wave Transform, SWT) was introduced in
[1] to make it possible to represent the frequency domain of the results of any
analysis carried out with the SWM. The values of fi , for i = 1, 2, . . . , n, are
plotted on the x-axis of an orthogonal Cartesian coordinate system. For every
fi , the value of the corresponding Ci is represented by a vertical bar whose value
is seen on the y-axis.
The SWT corresponding to the sequence of 8 voltage values specified in figure
1 has been represented in figure 4 to display the information that was provided
quantitatively in more detail by the sequence of 8 dyads specified above.
Figure 4: SWT corresponding to the time series composed of the sequence of 8
voltage measurements given in section 2
13
3
Description of an algorithm to facilitate the
determination of the required system of linear
algebraic equations
Based on the regularities present in the tables of coefficients such as in figure
2, the algorithm described here may be used to determine the system of linear
algebraic equations to be solved whenever the SWM is used to analyze a time
series.
For this purpose, let Q be the integer quotient in a division operation, and
R the integer remainder, as exemplified: For 10 ÷ 7, Q = 1 and R = 3; or for
7 ÷ 10, Q = 0 and R = 7.
In general, if N1 and N2 , are two natural numbers, the quotient of N1 and
N2 can be expressed in terms of Q and R as:
R
N1
=Q+
.
N2
N2
If N1 < N2 , then Q = 0 and R = N2 . These results will be used below.
If one considers a time series of n values (which can result from a sequence
of n measurements taken during a time interval ∆t) such that between any two
consecutive values of those n values the duration is the same, then the system
of n linear algebraic equations that must be solved in order to analyze that time
series with the SWM can be presented initially as follows:
n
X
C1,j = V1
j=1
n
X
C2,j = V2
j=1
n
X
(4)
C3,j = V3
j=1
..
.
n
X
Cn,j = Vn
j=1
V1 , V2 , V3 , . . . , Vn are the measured values corresponding to the first subinterval of the n subintervals into which ∆t is divided, to the second subinterval,
to the third subinterval, . . ., and the n-th subinterval of ∆t respectively.
Consider each of the coefficients Ci,j in the above system of equations (4). In
the first place, attention is given to the second subscript (j) of that coefficient.
Starting with j, lj = n − j + 1 is computed. (Recall that n is the number of
14
subintervals into which ∆t was divided.) Thus, for example, if n = 8 and j = 5,
then lj = 8 − 5 + 1 = 4.
Two other examples of how lj is computed are discussed below. If n = 10 and
j = 10, then lj = 10 − 10 + 1 = 1. If n = 10 and j = 1, then lj = 10 − 1 + 1 = 10.
Note that lj is the length of the semi-wave (that is, of the half-wave) corresponding to the train of square waves Sj , expressed in the number of subintervals
in ∆t.
For each coefficient Ci,j , consideration must be given to the values of Q and
R resulting from the following division:
i
i
=
.
lj
n−j+1
A variable K is introduced for one of the following values: 0, 1, 2, 3, . . .; thus
the following result is obtained:
1. If (Q = 2K and R = 0), then Ci,j = −Cj
2. If (Q = 2K and R 6= 0), then Ci,j = +Cj
3. If (Q = 2K + 1 and R = 0), then Ci,j = +Cj
4. If (Q = 2K + 1 and R 6= 0), then Ci,j = −Cj
As an example of the application of this algorithm, the system of eight linear
algebraic equations from section 2 will be obtained once again. Initially, this
system of equations can be presented as follows:
15
8
X
C1,j =
84 mV
8
X
C2,j =
−152 mV
8
X
C3,j =
63 mV
8
X
C4,j =
98 mV
8
X
C5,j =
−35 mV
8
X
C6,j =
0 mV
8
X
C7,j =
145 mV
8
X
C8,j =
−14 mV
j=1
j=1
j=1
j=1
j=1
j=1
j=1
j=1
Note that in the above system of equations, the first subscript of each coefficient i, for i = 1, 2, 3, . . . , 8, indicates the order of the equation itself in which
that coefficient appears; that is, the first, second, third, . . . or eighth equation
and the second coefficient j, for j = 1, 2, 3, . . . , 8 specifies the order in which that
coefficient is present in the given equation (first, second third, . . . or eighth).
Thus, for example, C5,4 is a coefficient present in the fifth of the above equations
and it appears in the fourth place of that equation.
Each coefficient Ci,j of the 64 coefficients in the above system of equations
can then be replaced by −Cj or by +Cj , as established in 1), 2), 3) and 4).
When proceeding in this way, the system of linear algebraic equations (1)
mentioned in section 2 is obtained:
16
C1 + C2 + C3 + C4 + C5 + C6 + C7 + C8 =
84 mV
C1 + C2 + C3 + C4 + C5 + C6 + C7 − C8 =
−152 mV
C1 + C2 + C3 + C4 + C5 + C6 − C7 + C8 =
C1 + C2 + C3 + C4 + C5 − C6 − C7 − C8 =
63 mV
98 mV
C1 + C2 + C3 + C4 − C5 − C6 + C7 + C8 =
C1 + C2 + C3 − C4 − C5 − C6 + C7 − C8 =
−35 mV
0 mV
C1 + C2 − C3 − C4 − C5 + C6 − C7 + C8 =
C1 − C2 − C3 − C4 − C5 + C6 − C7 − C8 =
145 mV
−14 mV
(1)
In this system of equations (1) there are only 8 coefficients: Ci , for i =
1, 2, . . . , 8.
Hence this procedure makes it possible to compute, for each time series
composed of a sequence of n measured values, the values of the n coefficients
Ci , for i = 1, 2, . . . , 8, appearing in the system of n linear algebraic equations
that is generated when analyzing the time series by using the SWM. Equation
(3) makes it possible to compute the frequency of each of the n trains of square
waves S1 , S2 , . . . , Sn .
4
Anlysis of a time series generated especially
to illustrate essential features of the SWM
The objective of this section is to emphasize the following characteristic of the
SWM as a tool for the analysis of time series: The method remains applicable
even when the changes in the value of the variable from which the sequence of
samples is obtained are entirely unforeseeable; and the approximation provided
for the measured values has a very high quality (i. e., the difference between any
of the measured values and the corresponding computed value is very slight).
A random number generator (the MRNG [5, 6, 7]) was used to generate
10, 000 values between −99.99999 and 99.99999.
When using the MRNG, the probability of any particular digit 0, 1, 2, . . . , 9
1
appearing is the same: 10
.
To generate each one of those 10,000 numerical values, the following was
done: If the first digit generated by the MRNG was between 0 and 4, inclusive,
it was admitted that the numerical value generated (NVG) was negative. If,
however, that digit was between 5 and 9, inclusive, it was accepted that the
NVG was positive. The second digit of those generated was taken as the first
digit of the whole part of the NVG. The third digit generated was taken as the
second digit of the whole part of the NVG. The fourth, fifth, sixth, seventh and
eighth digits generated were taken as the first, second, third, fourth and fifth
digits, respectively, of the decimal part of the NVG.
Each of the remaining values in the sequence of 10,000 numerical values to
be analyzed with the SWM was obtained using the same type of procedure.
17
Of course, a different sequence of 8 digits was generated by the MRNG to
be used to obtain each of those 10,000 numerical values.
It was supposed that the sequence of 10,000 values obtained by using the
MRNG corresponded to a time series of values measured during a lapse of
5 seconds (5 s) with a sampling frequency of 2.000 Hz. In other words, the
MRNG was used to simulate the 10,000 consecutive measurements of a time
series composed of a sequence of 10,000 numerical values.
The simulated time series described above is displayed in figure 5.
Figure 5: The simulated time series of 10,000 numerical values
The first 100 values of that numerical series of 10,000 are shown below:
18
V1 = −62.17387
V2 = −77.8189
V3 = −86.98077
V4 = −30.27255
V5 = −21.89399
V6 = −65.28596
V7 = −97.41397
V8 = 70.16625
V9 = −94.51527
V10 = −3.29921
V11 = 27.59454
V12 = −76.21755
V13 = −74.54863
V14 = −11.59495
V15 = 47.40731
V16 = 5.70653
V17 = 16.69057
V18 = −83.79124
V19 = −38.93865
V20 = 42.47807
V21 = 76.04696
V22 = −74.16542
V23 = 99.33202
V24 = 86.24249
V25 = −43.37761
V26 = 62.78057
V27 = 52.57981
V28 = −80.03298
V29 = −79.28799
V30 = −76.17741
V31 = 36.22582
V32 = 86.19701
V33 = −97.55277
V34 = 96.10761
V35 = −28.53992
V36 = −20.97347
V37 = −27.7922
V38 = −34.08936
V39 = 58.72335
V40 = 59.67262
V41 = 20.80554
V42 = 23.17323
V43 = 9.25608
V44 = −39.10634
V45 = 40.03058
V46 = −65.25953
V47 = 42.94391
V48 = −93.64582
V49 = 3.09509
V50 = −1.77666
V51 = −58.04794
V52 = −36.46843
V53 = 19.38409
V54 = −37.07554
V55 = −32.84694
V56 = −88.00845
V57 = −77.15092
V58 = −73.22327
V59 = −86.89494
V60 = 15.32544
V61 = −17.86576
V62 = 82.61901
V63 = 49.45424
V64 = 81.66214
V65 = 60.47497
V66 = 41.39753
V67 = −78.66478
V68 = −70.65624
V69 = −83.05503
V70 = −31.61922
V71 = −66.50127
V72 = −49.22007
V73 = −42.51459
V74 = 1.38873
V75 = −78.32747
V76 = −47.12626
V77 = 16.5785
V78 = 38.43836
V79 = −53.78808
V80 = −78.11808
V81 = −80.16334
V82 = 46.22563
V83 = 16.87193
V84 = 22.48866
V85 = 81.87053
V86 = −27.30575
V87 = −33.18708
V88 = 39.52277
V89 = 28.95455
V90 = −40.53147
V91 = −43.82255
V92 = −54.56893
V93 = −47.19443
V94 = −56.6021
V95 = −22.46162
V96 = 38.18652
V97 = 73.71899
V98 = 27.59394
V99 = 0.41868
V100 = 98.63304
The first 100 dyads (fi , Ci ), for i = 1, 2, . . . , 100 (resulting from the analysis
using the SWM) of the time series of 10,000 values is as follows:
19
(0.100000; −18065.729975)
(0.100010; −85.317955)
(0.100020; −100.109675)
(0.100030; −91.989130)
(0.100040; 768.823705)
(0.100050; −54.968935)
(0.100060; 142.557690)
(0.100070; 40.323305)
(0.100080; −184.475615)
(0.100090; −69.523010)
(0.100100; 325.761985)
(0.100110; 55.551825)
(0.100120; −134.091175)
(0.100130; 47.942450)
(0.100140; 27.621050)
(0.100150; 22.796750)
(0.100160; 13883.376575)
(0.100170; −12.899225)
(0.100180; −328.522275)
(0.100190; 29.374290)
(0.100200; −108.606305)
(0.100210; −85.847715)
(0.100220; 187.059175)
(0.100231; 12.679740)
(0.100241; −109.398105)
(0.100251; 108.646820)
(0.100261; −38.852280)
(0.100271; −83.227525)
(0.100281; 399.458855)
(0.100291; −156.149795)
(0.100301; −105.862070)
(0.100311; −22.212100)
(0.100321; 910.844845)
(0.100331; −48.628120)
(0.100341; 93.884360)
(0.100351; 33.974930)
(0.100361; −289.039710)
(0.100371; −154.583500)
(0.100381; 3.959370)
(0.100392; 50.950590)
(0.100402; 1268.174905)
(0.100412; −47.335845)
(0.100422; 114.977245)
(0.100432; 24.150720)
(0.100442; 237.504795)
(0.100452; 28.773410)
(0.100462; 134.511410)
(0.100472; −0.563565)
(0.100482; −1150.327445)
(0.100492; 22.801230)
(0.100503; 38.280880)
(0.100513; −20.427170)
(0.100523; −17.161430)
(0.100533; −52.007925)
(0.100543; −11.471110)
(0.100553; 280.304525)
(0.100563; 458.847200)
(0.100573; 77.849500)
(0.100583; −33.323975)
(0.100594; −25.913470)
(0.100604; −523.193475)
(0.100614; 129.402450)
(0.100624; −98.541910)
(0.100634; 138.864805)
(0.100644; −1692.771570)
(0.100654; 3.439290)
(0.100664; −30.526455)
(0.100675; −209.547145)
(0.100685; −47.459485)
(0.100695; 31.143430)
(0.100705; −4.459135)
(0.100715; 2.026140)
(0.100725; −137.505715)
(0.100735; 74.145900)
(0.100746; 119.423625)
(0.100756; 44.214730)
(0.100766; −3.829490)
(0.100776; −1.884085)
(0.100786; 6.228255)
(0.100796; 24.658120)
(0.100806; 290.612220)
(0.100817; −75.545490)
(0.100827; −51.233725)
(0.100837; −184.019420)
(0.100847; −188.399045)
(0.100857; −55.360550)
(0.100867; −7.625295)
(0.100878; −55.594890)
(0.100888; −1279.130445)
(0.100898; 124.454525)
(0.100908; −85.243345)
(0.100918; −145.174030)
(0.100929; 87.489570)
(0.100939; −94.767190)
(0.100949; 208.147540)
(0.100959; 15.027625)
(0.100969; −213.984295)
(0.100980; 88.275250)
(0.100990; −39.121275)
(0.101000; −17.187885)
A partial display of the results obtained by using the SWM is presented in
figure 6.
20
Figure 6: Partial view of the SWT corresponding to the analysis (using the
SWM) of the time series considered with 10,000 numerical values
The complete specification of the time series of 10,000 numerical values analyzed by the SWM and the corresponding sequence of 10,000 dyads of the
type (fi , Ci ), for i = 1, 2, 3, . . . , 10, 000, can be found in supplementary material available in the official page of the group (data points: http://www.
appliedmathgroup.org/en/data.csv, dyads: http://www.appliedmathgroup.
org/en/dyads.csv).
The approximation achieved (with the SWM) to each of the numerical values of the time series is outstanding. Vi , for i = 1, 2, . . . , 10, 000, will designate
the i-th of those values, and Vicomp will refer to the corresponding approximation obtained by the SWM. Vi − Vicomp is the absolute value of the difference
between the two values. Of course, there will be 10,000 absolute values of this
type. The maximum of those absolute values can be computed:
max Vi − Vicomp = 0.0000000000009379.
5
Discussion and prospects
Consideration has been given to the application of the SWM to time series such
that the value of the time interval between any two consecutive values remains
constant. Specialists in a certain type of signal usually have the necessary tools
to determine the minimum sampling frequency required to obtain a sequence of
measured values of that type of signal, during a specific time interval, such that
the sequence of values, or time series, can be considered to be an acceptable
digital version of that signal, in that interval. Suppose that a particular time
series is obtained by using that minimum sampling frequency or above. In that
21
case, the analysis with the SWM of that time series is also a valid analysis of
the corresponding signal, in that interval.
Section 4 of this article provides strong support for the criterion that the
SWM may be successfully applied even to acceptable digital versions of signals
that have many abrupt changes.
The SWT source code in MATLAB is available on the official page of the
group [8], and in the official GitHub repository [9].
Future articles will deal with the following topics:
I A general systematic approach for the use of the SWM for the analysis of
functions of n variables, for n = 1, 2, 3, . . .; and
II Ways in which the use of the SWM can contribute to 1) the elimination of
noise in different types of signals, and 2) the compression of information.
References
[1] Skliar O., Monge R. E., Oviedo G. and Gapper S. (2016). “A new method
for the analysis of signals: The Square Wave Transform”, Revista de
Matemática: Teorı́a y Aplicaciones, Vol. 23(1), pp. 85–110.
[2] Skliar, O.; Medina, V.; Monge, R. E. (2008) “A new method for the analysis
of signals: The Square Wave Method”, Revista de Matemática. Teorı́a y
Aplicaciones 15(2): 109–129.
[3] Skliar, O.; Oviedo, G.; Monge, R. E.; Medina, V.; Gapper, S. (2013) “A
new method for the analysis of images: The Square Wave Method”, Revista
de Matemática. Teorı́a y Aplicaciones 20(2): 133–153.
[4] Box, G. E. P.; Jenkins, G. M.; Reinsel, G. C.; Ljung, G. M. (2015) Time
Series Analysis: Forecasting and Control, Wiley, New York.
[5] Skliar O., Monge R. E., Gapper S. and Oviedo G. (2012). “A Mathematical
Random Number Generator (MRNG)”, arXiv :1211.5052 [cs.NA].
[6] Skliar, O.; Monge, R. E.; Oviedo, G.; Gapper, S. (2014) Square Wave
Transform Tool (online), http://www.appliedmathgroup.org/en/numm.
htm, consulted 20/5/2016.
[7] MIT Technology Review. (November 2012) Other Interesting arXiv
Papers This Week, https://www.technologyreview.com/s/507791/
other-interesting-arxiv-papers-this-week, consulted 10/6/2016.
[8] Monge, R. E.; Skliar, O.; Gapper, S. (2016) Computer Code (online), http:
//www.appliedmathgroup.org/en/software.htm, consulted 28/7/2016.
[9] Monge, R. E.; Skliar, O.; Gapper, S. (2016) Signal/Image analysis repository (online),
https://github.com/AppliedMathGroup/
SignalImageAnalysis/tree/master/SWT, consulted 28/7/2016.
22