<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>How to implement a simple system for fast data analysis</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>A. Description</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Kamil Rusin Faculty of Applied Mathematics Silesian University of Technology Kaszubska 23</institution>
          ,
          <addr-line>Gliwice, 44-100</addr-line>
          ,
          <country country="PL">Poland</country>
        </aff>
      </contrib-group>
      <fpage>28</fpage>
      <lpage>31</lpage>
      <abstract>
        <p>-Data analysis is important in our world. It is worth to get to know how data analysis work and how it can be implemented in a simple way. Fast Fourier Transform is very well known in scientific disciplines related to sound. It will be explain how it does work and which formulas should be used. This transform has various applications that affect our lives,especially analysis of sounds and signals in the world. In this paper, a simple system for fast analysis of frequencies will be implemented with explanatory. Scripts are used to divide the program into tasks that one specified programming language process data better than the other. Python and C# are one of the most popular programming languages. They differ on some issues that will be explained and also good programming practices will be presented.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>I. INTRODUCTION</title>
      <p>
        Data analysis takes part in our projects, examinations. We need
to use a special designed system for processing data that we get
during calculations of our programs. The speed of that analysis is
defining how useful our applications are for users. It must be done fast
and simple systems are the key to reaching that attribute. Moreover,
data analysis is used in a psychological researches. Exploratory data
analysis is a strategy, which states that people should have an open
mind to alternative possibilities. That attitude is about how data
analysis should be carried out[
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]. Matthew A. Waller and Stanley
E. Fawcett see the increasing popularity of data analysis. Moreover
they know that it requires knowledge and skills. They say that data
science and big data are also relevant to supply chain research and
education. They examine possible applications of it in practice and
provide examples of research questions from these applications [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ].
The analysis of data is more widely used in data mining, which is
used for automated discovery of statistical relationships and schemes
in very large databases. It is new discipline that has big potential
[
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]. The reason why data mining is developing really fast is that the
data contains valuable information for owners of many corporations.
You can find a large number of hidden dependencies in them, which,
for example, can greatly improve the promotion of certain products.
Jiawei Han, Jian Pei and Micheline Kamber explain the essence of
data analysis [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. They say why it is used and show what patterns
and technologies are currently used. Moreover, they also explain how
to analyze, assign and how to properly store and manage data.
      </p>
      <p>As an example in this paper we will be considering how to
implement simple system for analysing periodic functions and transforming
them into frequency values using Fast Fourier Transform algorithm.
There will be also explained how this algorithm works and how it
can be applied in our purposes.
c 2019 for this paper by its authors. Use permitted under Creative
Commons License Attribution 4.0 International (CC BY 4.0)</p>
    </sec>
    <sec id="sec-2">
      <title>II. FAST FOURIER TRANSFORM</title>
    </sec>
    <sec id="sec-3">
      <title>Divide DFT equation into two parts by indexes:</title>
      <p>x2n e i2 (2n)k=N +
x2n 1 e i2 (2n+1)k=N =
(2)
(N=2) 1)</p>
      <p>X
n=0
x2n</p>
      <p>WNn=k2 + WNk
(N=2) 1)</p>
      <p>X
n=0
x2n+1</p>
      <p>WNn=k2</p>
    </sec>
    <sec id="sec-4">
      <title>Define two additional formulas:</title>
      <p>WN = e i2 =N
xk =
(N=2) 1)</p>
      <p>X
n=0
(N=2) 1)</p>
      <p>X
n=0
yn = x2n
zn = x2n+1
(1)
(3)
(4)</p>
      <p>For every k belonging to the set 0; 1; 2; :::; N=2
dependencies:
1 there are two
Yk =
Zk =
(N=2) 1</p>
      <p>X
r=0
(N=2) 1</p>
      <p>X
r=0
yr
zr</p>
      <p>WNkr=2</p>
      <p>WNkr=2
W N(N=2)+k =</p>
      <p>WNk</p>
      <p>Xk+N =
(N=2) 1</p>
      <p>X</p>
      <p>
        In this way, Discrete Fourier Transform is divided into subsequent
DFTs until only two-point DFTs are obtained. Then sets must be
folded. Therefore, it is important to assume the number N as the
power of two [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ].
(5)
(6)
(7)
(8)
of FFT is the rapid multiplication of polynomials. When we have
two polynomials of various degrees, we can align them by adding
coefficients equal to 0 to the lower degree polynomial. Next step
is to reindexate the indicators and the polynomial coefficients are
treated as the coordinates of the vectors. The newly created vector is
their weave. Using the Fourier transformation definition for a function
weave, we can count the FFT of both vectors as well as the inverse
Fourier transform of their convolution. Fast Fourier Transform can
also be used to solve two- or three-dimensional Poisson equations.
The FFT is used in digital audio processing, digital image processing
and speech. The signal can be processed in real time. It is also used
in compressing MP3 music files. Using the same group of algorithms,
Discrete Cosine Transform can be used in order to compress images
in .jpg format. This transformation divides the video image into
64point blocks. Each of these blocks is compressed separately, then
by combining them, a distorted picture is created and, as a result,
high degradation of video quality is obtained. In FFT, we move in
the frequency domain and this is the reason for a different look at
the issue of image filtration. Weave function can be calculated more
easily. The image after Fourier transform is high-pass filtered, this
means zeroing the central part of the image that contains spectrum for
low frequencies. The image obtained in the results of this filtration
is added to the source image and because of that there is a sharp
image.
      </p>
    </sec>
    <sec id="sec-5">
      <title>III. SYSTEM FOR ANALYSIS</title>
      <sec id="sec-5-1">
        <title>A. Scripts</title>
        <p>This system combines several elements whose task is to process
the data. The Batch script is the main part that is responsible for
support of this program. It coordinates the work of the remaining
scripts and at the appropriate moments turns on the C# and Python
scripts. The purpose of the program is to calculate the frequency
of given functions by using the RADIX-2 FFT algorithm. It allows
to create graphs of amplitude. This program processes the function
along with the amount of samples using the mentioned algorithm. It
performs a specific amount of operations on complex numbers. After
all calculations are done, it creates output file and runs Python script
that creates statistics of all information and generates HTML page.</p>
        <p>The system starts with running batch script, which provides us a
simple menu for controlling the program. Menu has several options
such as displaying the user manual, making a backup of our files
and data that we obtained through the program. This is important to
avoid accidental deletion of data. It also starts the second script that
calculates FFT frequencies.</p>
        <p>Each periodic signal can be presented in the form of a sum of
sinusoidal signals with different frequencies and different amplitudes.
Thanks to FFT we are able to accurately assess components of a
given signal is made of. The FFT result is the spectrum and it
allows for fast and precise validation whether the components of
the output signal belong to the work of a healthy device or they are
a sign of deterioration of the technical condition. In other words it
is used to filter the signal, distinguish particular waves. For example,
we can conclude only a part of given band in the output signal
or define which parts of the band we want to omit. This can also
be used to delay the signal, transmit from specific frequency. The
greater the sampling frequency, the better the details of the analog
signal in digital form are preserved. Another mathematical application</p>
        <p>Firstly, C# script checks how many data we provided and looks
for text files in an input folder. In every two lines of these text files
are a formula of function and number of samples to process. The
correct function has a variable x. The special mathematics library
is responsible for reading it properly. In a radix-2 Fast Fourier
Transform algorithm number of samples must be a power of two.
This is required by dividing the samples due to the parity. Then all
calculations are performed and lists of frequency values are written
to output files. To avoid incorrect reading and writing of files during
the operation of the system we should ensure that the same type of
encoding is set for all files.</p>
        <p>After all calculations are done main script automatically turns
off C# script and then calls Python script, which creates statistics
of processed data written in an output files to HTML file. It also
generates a table, which rows contains number of sample and
frequency value. Batch script also runs that page, so the whole chain
of events happens within seconds. The process is automated. There
is also an alternative to calling a Python script. We can use special
interpreter in the current C# script and the Process class. To know
more about that class it is recommended to read official Microsoft
documentation.</p>
      </sec>
      <sec id="sec-5-2">
        <title>B. Planning a system</title>
        <p>First of all, the structure of a system must be made. This is
a framework, which program is based on. Then scripts can be
programmed step by step and that does not lead to organizational
problems. In analysed example the structure is made from 3 scripts
with different objective. First one is to control others and set possible
options. The second one is to make all calculations and the third one
is to gather the data and analyse it in order to make statistics.</p>
        <p>Batch provides very useful command call that opens us a way to
launch second script. It pauses parent batch program until the second
one is finished. There is also an option that allows us to call a script
with arguments. That is how an options edited in the main script can
be forwarded. To know more about call command it is recommended
to read official documentation of Batch.</p>
        <p>Use of second script depends on user needs. It is written in
highlevel programming language with high abstraction that allows to
program even difficult tasks, complicated mathematical problems or
precisely defined ways of processing information. All operations are
held here. There are a lot of useful frameworks for every language
that can help with calculations and processing.</p>
        <p>The statistics are separated from the previous script for easier
organization and implementation. In our example it was implemented
with Python. It has a various built-in mathematical functions that
accelerates our program. In this implementation Python script
generates a table with frequency values for a given sample and information
about median, mean, various sums or number of processed functions.
To view that data in an eye-friendly way this script also generates
HTML file that is launched with call command in Batch script after
C# and Python scripts are done, so the main script is not longer
paused.</p>
      </sec>
      <sec id="sec-5-3">
        <title>C. Data and neural network</title>
        <p>
          It is worth considering using a system for data analysis in machine
learning. Neural networks process a lot of data [
          <xref ref-type="bibr" rid="ref7">7</xref>
          ]–[
          <xref ref-type="bibr" rid="ref10">10</xref>
          ]. There are
a lot of ready to use datasets for various purposes. For example,
our program needs to analyse sounds provided by external library.
There can be implemented simple system for data flow. First script
can subject data to a Fast Fourier Transform algorithm and save
information to a file. Then, second one can read it and process in
a way a programmer wants. It has wide range of applications in
a voice control for example at smart houses. It should be working
on an affordable platforms available at home. The processing time
should be relatively fast. When sound is recorded noise is always
present. To properly recognize a speech, it should be removed and
only those frequencies should be kept, which a person is able to speak
in. In this case, Fast Fourier Transform is very helpful. Two filters
are most often selected: low-pass and middle-pass [
          <xref ref-type="bibr" rid="ref11">11</xref>
          ]. A system can
be created that records the sound and then for example sends it to
the next program on the workstation that will process the speech.
There is an algorithm that allows to quickly identify commands.
First of all, an identifier is created for each word. Secondly, the
correlation coefficient is calculated. Then the pattern is split into a
fixed number of time intervals, which are then subjected to a Fast
Fourier Transform. The next step is to calculate totals in intervals
and create a command identifier. Finally, the generated identifiers,
corresponding to the recorded commands, are compared with patterns,
which results in the final decision of the program. This method is
written in detail in this paper [
          <xref ref-type="bibr" rid="ref12">12</xref>
          ]. Another application of simple
system for fast data analysis is in neural networks.
        </p>
      </sec>
      <sec id="sec-5-4">
        <title>D. Good practices before starting to code</title>
        <p>Planning is a first step of every project. It should be determined
what the project will accomplish. Once it is done, it allows to avoid
rewriting code and keeping the notes of what should be changed.</p>
        <p>First, write the basic idea of a project. Then, read it once more
and add more sentences describing what the application’s
functionalities will be. Secondly, think once more and delete unnecessary
assumptions. It is recommended to construct logic network diagram
and detailed decomposition of the project to clearly see how the data
will be processed, in order to make it efficient.</p>
        <p>When the first code is written, the entire functionality should be
analysed once again and, if necessary, extended with further
functionalities. Logical sequence of activities can be developed deeper.</p>
        <p>Moreover, clean code is also an important element in projects and
implementations. Following good practices results in minimizing the
time that other person has to spend on reading and understanding
the code. First thing worth to remember is to set relatively short and
meaningful names for classes, methods, functions, variables. It means
that a person is able to guess the purpose of using e.g. that method,
variable.</p>
        <p>If it is hard to name them in a relatively short way or it has
a deeper meaning, it is also recommended to use comments. It will
help in clarification. They should be also used in explaining the code.
Nevertheless comments should not be a way to explain programmers
wrong code. To prevent that kind of code there is also a practice,
which allows methods or functions to perform only one task, it is
called Single responsibility principle introduced by Robert C.Martin.
If a one style of writing is chosen, it should be used everywhere.
Mixing styles may lead to a complete opposite of the practices that
are used.</p>
        <p>While planning a structure of our program, the language of all
scripts must be chosen. C# and Python were chosen for two scripts in
the example project for this paper. The advantages and disadvantages
should be considered. First of all, Python is a dynamically-interpreted
language, while C# is statically-typed compiled language. Python is
also well known for its great libraries. They are open-source and have
a wide range of applications. They can work only with a defined
Python versions. That may lead to the moment, when two useful
libraries use different language versions. Python also has a dynamic
typing. It means that every variable is bond only to an object and
can be assigned to a different types during the program. On the other
hand C# has an automatic garbage collector that manages memory
and saves computer resources. C# also allows to extend existing types
by adding new methods. That language is backed by producers and
supported at various programming aspects.</p>
      </sec>
      <sec id="sec-5-5">
        <title>E. Tests</title>
        <p>In order to test the system, the periodic functions were prepared.
2000 files were created that each of them contained 4 functions and
an information about number of samples for each function. Every
file was analyzed. Math library was used to read a function from a
string and do all calculation required to obtain a frequency value for
a given argument.</p>
        <p>First script was run for 100 files. The time was measure from the
point of reading a function to the moment of a last calculation. After
each iteration number of analyzed files was increased by 100. As
can be seen in a 6, the time (measured in miliseconds) of processing
increased linearly. First iteration was done under 1781 miliseconds.
The second one analyzed the data faster by 208 miliseconds than
first iteration comparing the values after 100 files. Interesting is the
fact that counting from iteration number 10, the speed of analyse per
100 files is increasing. The lowest value of analysing the data was
17,81 miliseconds during the first iteration. Data from 2000 files was
processed in 24414 miliseconds.</p>
      </sec>
    </sec>
    <sec id="sec-6">
      <title>IV. FINAL REMARKS</title>
      <p>
        Implementing simple structure for data analysis can be done
seamlessly. Developers must keep in mind the compatibility of the
file encoding and following the scheme. It is worth considering which
programming language to choose for a given script, because the
volume of built-in functions may affect the delay of the extended
program operation. Sound planning of program calculations can
significantly increase its efficiency. As introduced in this paper, Fast
Fourier Transform has various possible applications ranging from
mathematical to implementation in devices in Smart Home and neural
networks. It can be used to recognize speech and voice commands.
This could be helpful for disabled people [
        <xref ref-type="bibr" rid="ref12">12</xref>
        ].
      </p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>C. H.</given-names>
            <surname>Yu</surname>
          </string-name>
          , “
          <article-title>Exploratory data analysis</article-title>
          ,
          <source>” Methods</source>
          , vol.
          <volume>2</volume>
          , pp.
          <fpage>131</fpage>
          -
          <lpage>160</lpage>
          ,
          <year>1977</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>M. A.</given-names>
            <surname>Waller</surname>
          </string-name>
          and
          <string-name>
            <given-names>S. E.</given-names>
            <surname>Fawcett</surname>
          </string-name>
          , “
          <article-title>Data science, predictive analytics, and big data: a revolution that will transform supply chain design and management</article-title>
          ,
          <source>” Journal of Business Logistics</source>
          , vol.
          <volume>34</volume>
          , no.
          <issue>2</issue>
          , pp.
          <fpage>77</fpage>
          -
          <lpage>84</lpage>
          ,
          <year>2013</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>D. J.</given-names>
            <surname>Hand</surname>
          </string-name>
          , “Data mining,
          <source>” Encyclopedia of Environmetrics</source>
          , vol.
          <volume>2</volume>
          ,
          <year>2006</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>J.</given-names>
            <surname>Han</surname>
          </string-name>
          ,
          <string-name>
            <surname>J</surname>
          </string-name>
          . Pei, and
          <string-name>
            <given-names>M.</given-names>
            <surname>Kamber</surname>
          </string-name>
          ,
          <article-title>Data mining: concepts and techniques</article-title>
          .
          <source>Elsevier</source>
          ,
          <year>2011</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>W. T.</given-names>
            <surname>Cochran</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J. W.</given-names>
            <surname>Cooley</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D. L.</given-names>
            <surname>Favin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H. D.</given-names>
            <surname>Helms</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R. A.</given-names>
            <surname>Kaenel</surname>
          </string-name>
          ,
          <string-name>
            <given-names>W. W.</given-names>
            <surname>Lang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G. C.</given-names>
            <surname>Maling</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D. E.</given-names>
            <surname>Nelson</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C. M.</given-names>
            <surname>Rader</surname>
          </string-name>
          , and
          <string-name>
            <given-names>P. D.</given-names>
            <surname>Welch</surname>
          </string-name>
          , “
          <article-title>What is the fast fourier transform?” Proceedings of the IEEE</article-title>
          , vol.
          <volume>55</volume>
          , no.
          <issue>10</issue>
          , pp.
          <fpage>1664</fpage>
          -
          <lpage>1674</lpage>
          ,
          <year>1967</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>T. P.</given-names>
            <surname>Zielin</surname>
          </string-name>
          <article-title>´ski, Cyfrowe przetwarzanie sygnałów: od teorii do zastosowan´</article-title>
          .
          <source>Wydawnictwa Komunikacji Ła˛cznos´ci</source>
          ,
          <year>2005</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>M.</given-names>
            <surname>Woz</surname>
          </string-name>
          ´niak, D. Połap, G. Capizzi,
          <string-name>
            <given-names>G. L.</given-names>
            <surname>Sciuto</surname>
          </string-name>
          ,
          <string-name>
            <surname>L.</surname>
          </string-name>
          <article-title>Kos´mider, and</article-title>
          K. Frankiewicz, “
          <article-title>Small lung nodules detection based on local variance analysis and probabilistic neural network,” Computer methods and programs in biomedicine</article-title>
          , vol.
          <volume>161</volume>
          , pp.
          <fpage>173</fpage>
          -
          <lpage>180</lpage>
          ,
          <year>2018</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>M.</given-names>
            <surname>Wozniak</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Polap</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Kosmider</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Napoli</surname>
          </string-name>
          , and E. Tramontana, “
          <article-title>A novel approach toward x-ray images classifier</article-title>
          ,” in
          <source>2015 IEEE Symposium Series on Computational Intelligence. IEEE</source>
          ,
          <year>2015</year>
          , pp.
          <fpage>1635</fpage>
          -
          <lpage>1641</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>U. R.</given-names>
            <surname>Acharya</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S. L.</given-names>
            <surname>Oh</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Hagiwara</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J. H.</given-names>
            <surname>Tan</surname>
          </string-name>
          , and
          <string-name>
            <given-names>H.</given-names>
            <surname>Adeli</surname>
          </string-name>
          , “
          <article-title>Deep convolutional neural network for the automated detection and diagnosis of seizure using eeg signals,” Computers in biology and medicine</article-title>
          , vol.
          <volume>100</volume>
          , pp.
          <fpage>270</fpage>
          -
          <lpage>278</lpage>
          ,
          <year>2018</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <given-names>D.</given-names>
            <surname>Połap</surname>
          </string-name>
          and
          <string-name>
            <surname>M.</surname>
          </string-name>
          <article-title>Woz´niak, “Flexible neural network architecture for handwritten signatures recognition</article-title>
          ,”
          <source>International Journal of Electronics and Telecommunications</source>
          , vol.
          <volume>62</volume>
          , no.
          <issue>2</issue>
          , pp.
          <fpage>197</fpage>
          -
          <lpage>202</lpage>
          ,
          <year>2016</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <string-name>
            <given-names>P.</given-names>
            <surname>Walendowski</surname>
          </string-name>
          , “
          <article-title>Zastosowanie sieci neuronowych typu svm do rozpoznawania mowy,” Praca doktorska</article-title>
          ,
          <source>Politechnika Wrocławska</source>
          ,
          <year>2008</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [12]
          <string-name>
            <surname>A. S</surname>
          </string-name>
          <article-title>´ liwin´ski and</article-title>
          K. Tomczewski, “
          <article-title>Badania moz˙liwos´ci rozpoznawania mowy w autonomicznych systemach sterowania</article-title>
          ,” Poznan University of Technology Academic Journals. Electrical Engineering, no.
          <issue>88</issue>
          , pp.
          <fpage>79</fpage>
          -
          <lpage>88</lpage>
          ,
          <year>2016</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>