<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE article PUBLIC "-//NLM//DTD Journal Publishing DTD v3.0 20080202//EN" "http://dtd.nlm.nih.gov/publishing/3.0/journalpublishing3.dtd">
<article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="3.0" xml:lang="en" article-type="research article">
 <front>
  <journal-meta>
   <journal-id journal-id-type="publisher-id">
    jcc
   </journal-id>
   <journal-title-group>
    <journal-title>
     Journal of Computer and Communications
    </journal-title>
   </journal-title-group>
   <issn pub-type="epub">
    2327-5219
   </issn>
   <issn publication-format="print">
    2327-5227
   </issn>
   <publisher>
    <publisher-name>
     Scientific Research Publishing
    </publisher-name>
   </publisher>
  </journal-meta>
  <article-meta>
   <article-id pub-id-type="doi">
    10.4236/jcc.2025.135002
   </article-id>
   <article-id pub-id-type="publisher-id">
    jcc-142617
   </article-id>
   <article-categories>
    <subj-group subj-group-type="heading">
     <subject>
      Articles
     </subject>
    </subj-group>
    <subj-group subj-group-type="Discipline-v2">
     <subject>
      Computer Science 
     </subject>
     <subject>
       Communications
     </subject>
    </subj-group>
   </article-categories>
   <title-group>
    Software for a Novel Fuzzy Time Series Forecasting Model Based on Balanced Tree Data Structures
   </title-group>
   <contrib-group>
    <contrib contrib-type="author" xlink:type="simple">
     <name name-style="western">
      <surname>
       Thiago Henrique Barbosa de Carvalho
      </surname>
      <given-names>
       Tavares
      </given-names>
     </name> 
     <xref ref-type="aff" rid="aff1"> 
      <sup>1</sup>
     </xref>
    </contrib>
    <contrib contrib-type="author" xlink:type="simple">
     <name name-style="western">
      <surname>
       Bruno Pérez
      </surname>
      <given-names>
       Ferreira
      </given-names>
     </name> 
     <xref ref-type="aff" rid="aff2"> 
      <sup>2</sup>
     </xref>
    </contrib>
    <contrib contrib-type="author" xlink:type="simple">
     <name name-style="western">
      <surname>
       Eduardo Mazoni Andrade Marçal
      </surname>
      <given-names>
       Mendes
      </given-names>
     </name> 
     <xref ref-type="aff" rid="aff3"> 
      <sup>3</sup>
     </xref>
    </contrib>
   </contrib-group> 
   <aff id="aff1">
    <addr-line>
     aDepartamento de Engenharia de Controle e Automação, Instituto Federal de Minas Gerais, Ibirité, Brasil
    </addr-line> 
   </aff> 
   <aff id="aff2">
    <addr-line>
     aDepartamento de Ciências Administrativas, Faculdade de Ciências Econômicas, Universidade Federal de Minas Gerais, Belo Horizonte, Brasil
    </addr-line> 
   </aff> 
   <aff id="aff3">
    <addr-line>
     aDepartamento de Engenharia Eletrênica, Universidade Federal de Minas Gerais, Escola de Engenharia, Belo Horizonte, Brasil
    </addr-line> 
   </aff> 
   <pub-date pub-type="epub">
    <day>
     14
    </day> 
    <month>
     05
    </month>
    <year>
     2025
    </year>
   </pub-date> 
   <volume>
    13
   </volume> 
   <issue>
    05
   </issue>
   <fpage>
    13
   </fpage>
   <lpage>
    28
   </lpage>
   <history>
    <date date-type="received">
     <day>
      28,
     </day>
     <month>
      January
     </month>
     <year>
      2025
     </year>
    </date>
    <date date-type="published">
     <day>
      13,
     </day>
     <month>
      January
     </month>
     <year>
      2025
     </year> 
    </date> 
    <date date-type="accepted">
     <day>
      13,
     </day>
     <month>
      May
     </month>
     <year>
      2025
     </year> 
    </date>
   </history>
   <permissions>
    <copyright-statement>
     © Copyright 2014 by authors and Scientific Research Publishing Inc. 
    </copyright-statement>
    <copyright-year>
     2014
    </copyright-year>
    <license>
     <license-p>
      This work is licensed under the Creative Commons Attribution International License (CC BY). http://creativecommons.org/licenses/by/4.0/
     </license-p>
    </license>
   </permissions>
   <abstract>
    Predicting stock market trends remains a heavily researched topic due to the inherent complexity of market fluctuations, driven by subjective and often unpredictable factors. These challenges make accurate predictions difficult for traditional models. Fuzzy models address this issue by accounting for the uncertainty of market returns, thereby mitigating the influence of human emotions on predictions. A key component of these models is the use of data structures to define clusters effectively. In this context, this paper introduces a novel fuzzy model that leverages the red-black tree (RBT) data structure to enhance predictive capability. As a balanced binary search tree, the RBT plays a critical role in improving forecasting precision. A comparative analysis with existing fuzzy models from the literature demonstrates the superior performance of the proposed approach.
   </abstract>
   <kwd-group> 
    <kwd>
     Finance
    </kwd> 
    <kwd>
      Fuzzy
    </kwd> 
    <kwd>
      Statistics
    </kwd> 
    <kwd>
      Red-Black Tree
    </kwd> 
    <kwd>
      Machine Learning
    </kwd> 
    <kwd>
      Deep Learning
    </kwd>
   </kwd-group>
  </article-meta>
 </front>
 <body>
  <sec id="s1">
   <title>1. Introduction</title>
   <p>Investing in the stock market remains a challenge, as both the economy and finance are not deterministic processes. Research in financial forecasting has explored various model types and techniques, such as time series analysis using ARIMA <xref ref-type="bibr" rid="scirp.142617-1">
     [1]
    </xref> and fuzzy regression <xref ref-type="bibr" rid="scirp.142617-2">
     [2]
    </xref>. A model for predicting university enrollments based on fuzzy time series was proposed by <xref ref-type="bibr" rid="scirp.142617-3">
     [3]
    </xref>, and <xref ref-type="bibr" rid="scirp.142617-4">
     [4]
    </xref> argues that the interval lengths associated with fuzzy sets (also known as clusters) significantly and directly impact the forecasting procedure’s performance. A series of later works, including <xref ref-type="bibr" rid="scirp.142617-5">
     [5]
    </xref>-<xref ref-type="bibr" rid="scirp.142617-7">
     [7]
    </xref>, propose alternatives for determining the best interval lengths. These works emphasize that the interval lengths need not be identical, as suggested by <xref ref-type="bibr" rid="scirp.142617-8">
     [8]
    </xref>.</p>
   <p>A more advanced model based on the work from <xref ref-type="bibr" rid="scirp.142617-3">
     [3]
    </xref> explores a fuzzy weighted approach, in which the forecast considers how frequently a particular pattern appears in the fuzzy time series, as discussed by <xref ref-type="bibr" rid="scirp.142617-9">
     [9]
    </xref>. The work from <xref ref-type="bibr" rid="scirp.142617-10">
     [10]
    </xref> proposes a model where the universe of discourse is partitioned into clusters based on Schrödinger’s concepts from quantum mechanics. Additionally, the work from <xref ref-type="bibr" rid="scirp.142617-11">
     [11]
    </xref> suggests a model based on cumulative probability distributions, and the work from <xref ref-type="bibr" rid="scirp.142617-12">
     [12]
    </xref> introduces a model based on rough set rules. A central focus of many research efforts in fuzzy time series is the improved distribution of data mass into smaller groups (clusters) that share similar statistical characteristics. These efforts aim to develop tree-like data structures, as demonstrated by <xref ref-type="bibr" rid="scirp.142617-10">
     [10]
    </xref>. Red-black trees, which are balanced binary trees, have been extensively studied for their efficiency in node insertion and imbalance correction. A comprehensive discussion on red-black trees can be found in <xref ref-type="bibr" rid="scirp.142617-13">
     [13]
    </xref>.</p>
  </sec><sec id="s2">
   <title>2. Background Literature</title>
   <p>The work from <xref ref-type="bibr" rid="scirp.142617-6">
     [6]
    </xref> contributed to the development of a new method for clustering data, generating varying interval lengths for fuzzy sets. The work from <xref ref-type="bibr" rid="scirp.142617-14">
     [14]
    </xref> introduced a multi-variable method for fuzzy forecasting that combines fuzzy clustering and fuzzy interpolation techniques. The work from <xref ref-type="bibr" rid="scirp.142617-15">
     [15]
    </xref> proposed a method using a triangular membership function and extended autocorrelation functions. The GARCH (Generalized Auto-Regressive Conditional Heteroskedasticity) models are considered particularly suitable for economic and financial predictions, as they handle non-stationary data. A hybrid model combining GARCH and fuzzy linear regression is proposed in <xref ref-type="bibr" rid="scirp.142617-16">
     [16]
    </xref>, with a fuzzy sliding window variance developed to estimate forecast weights. The work from <xref ref-type="bibr" rid="scirp.142617-17">
     [17]
    </xref> introduces a model that integrates genetic algorithms (GA) with adaptive neuro-fuzzy inference systems (ANFIS) to improve models such as ARIMA and GARCH. The work from <xref ref-type="bibr" rid="scirp.142617-18">
     [18]
    </xref> uses a fuzzy forecasting model that helps stablish a relation between the main taxes fee in Brazil and the ammout of credit provided for nations having intentions in investing in that country. is it importnat to note, however, that other field of science also take advantage in fuzzy models, which can be observer in civil engineering from the paper published by <xref ref-type="bibr" rid="scirp.142617-19">
     [19]
    </xref>.</p>
   <p>Other works such as <xref ref-type="bibr" rid="scirp.142617-20">
     [20]
    </xref> show how a suuport decision systems can be developed using modern tools involving genetic algorithms. Different variables such as volume have its impacts analysed during forecasting procedures as in the work from <xref ref-type="bibr" rid="scirp.142617-21">
     [21]
    </xref>.</p>
   <p>Different works as <xref ref-type="bibr" rid="scirp.142617-22">
     [22]
    </xref>-<xref ref-type="bibr" rid="scirp.142617-25">
     [25]
    </xref> show various forecasting methos using fuzzy time series while the original work which described fuzzy mathematics can be seen at <xref ref-type="bibr" rid="scirp.142617-26">
     [26]
    </xref>.</p>
   <p>This paper proposes a new model for stock market forecasting, integrating fuzzy time series where the partitioning of the universe of discourse is based on transforming a red-black tree structure into clusters.</p>
  </sec><sec id="s3">
   <title>3. Materials and Methods</title>
   <p>This section presents the background literature on the main topics discussed in this paper: Fuzzy Time Series and Red-Black Trees. The objective is to provide the reader with a fundamental understanding of the mathematical principles underlying this work. Additionally, relevant references are included for those interested in exploring these topics in greater depth.</p>
   <sec id="s3_1">
    <title>3.1. Fuzzy Time Series</title>
    <p>A conventional time series is composed by real numbers whereas a fuzzy time series is composed by fuzzy sets <xref ref-type="bibr" rid="scirp.142617-27">
      [27]
     </xref>, where a fuzzy set is a class with fuzzy boundaries. In order to define a fuzzy time series let 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
        U 
      </mi> 
     </math> be the universe of discourse as defined in Equation 1 and a fuzzy set 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
        A 
      </mi> 
     </math> of 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
        U 
      </mi> 
     </math> is defined by Equation (2).</p>
    <p>
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         U 
       </mi> 
       <mo>
         = 
       </mo> 
       <mrow> 
        <mo>
          { 
        </mo> 
        <mrow> 
         <msub> 
          <mi>
            u 
          </mi> 
          <mn>
            1 
          </mn> 
         </msub> 
         <mo>
           , 
         </mo> 
         <msub> 
          <mi>
            u 
          </mi> 
          <mn>
            2 
          </mn> 
         </msub> 
         <mo>
           , 
         </mo> 
         <mo>
           ⋯ 
         </mo> 
         <mo>
           , 
         </mo> 
         <msub> 
          <mi>
            u 
          </mi> 
          <mi>
            n 
          </mi> 
         </msub> 
        </mrow> 
        <mo>
          } 
        </mo> 
       </mrow> 
      </mrow> 
     </math> (1)</p>
    <p>
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         A 
       </mi> 
       <mo>
         = 
       </mo> 
       <mrow> 
        <mo>
          { 
        </mo> 
        <mrow> 
         <mfrac> 
          <mrow> 
           <msub> 
            <mi>
              f 
            </mi> 
            <mi>
              A 
            </mi> 
           </msub> 
           <mrow> 
            <mo>
              ( 
            </mo> 
            <mrow> 
             <msub> 
              <mi>
                u 
              </mi> 
              <mn>
                1 
              </mn> 
             </msub> 
            </mrow> 
            <mo>
              ) 
            </mo> 
           </mrow> 
          </mrow> 
          <mrow> 
           <msub> 
            <mi>
              u 
            </mi> 
            <mn>
              1 
            </mn> 
           </msub> 
          </mrow> 
         </mfrac> 
         <mo>
           + 
         </mo> 
         <mfrac> 
          <mrow> 
           <msub> 
            <mi>
              f 
            </mi> 
            <mi>
              A 
            </mi> 
           </msub> 
           <mrow> 
            <mo>
              ( 
            </mo> 
            <mrow> 
             <msub> 
              <mi>
                u 
              </mi> 
              <mn>
                2 
              </mn> 
             </msub> 
            </mrow> 
            <mo>
              ) 
            </mo> 
           </mrow> 
          </mrow> 
          <mrow> 
           <msub> 
            <mi>
              u 
            </mi> 
            <mn>
              2 
            </mn> 
           </msub> 
          </mrow> 
         </mfrac> 
         <mo>
           + 
         </mo> 
         <mo>
           ⋯ 
         </mo> 
         <mo>
           + 
         </mo> 
         <mfrac> 
          <mrow> 
           <msub> 
            <mi>
              f 
            </mi> 
            <mi>
              A 
            </mi> 
           </msub> 
           <mrow> 
            <mo>
              ( 
            </mo> 
            <mrow> 
             <msub> 
              <mi>
                u 
              </mi> 
              <mi>
                n 
              </mi> 
             </msub> 
            </mrow> 
            <mo>
              ) 
            </mo> 
           </mrow> 
          </mrow> 
          <mrow> 
           <msub> 
            <mi>
              u 
            </mi> 
            <mi>
              n 
            </mi> 
           </msub> 
          </mrow> 
         </mfrac> 
        </mrow> 
        <mo>
          } 
        </mo> 
       </mrow> 
      </mrow> 
     </math> (2)</p>
    <p>Based on <xref ref-type="bibr" rid="scirp.142617-3">
      [3]
     </xref>, 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <msub> 
        <mi>
          f 
        </mi> 
        <mi>
          A 
        </mi> 
       </msub> 
      </mrow> 
     </math> is the membership function of 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
        A 
      </mi> 
     </math>, 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <msub> 
        <mi>
          f 
        </mi> 
        <mi>
          A 
        </mi> 
       </msub> 
       <mo>
         : 
       </mo> 
       <mi>
         U 
       </mi> 
       <mo>
         → 
       </mo> 
       <mrow> 
        <mo>
          [ 
        </mo> 
        <mrow> 
         <mn>
           0 
         </mn> 
         <mo>
           , 
         </mo> 
         <mn>
           1 
         </mn> 
        </mrow> 
        <mo>
          ] 
        </mo> 
       </mrow> 
      </mrow> 
     </math>. 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <msub> 
        <mi>
          f 
        </mi> 
        <mi>
          A 
        </mi> 
       </msub> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mrow> 
         <msub> 
          <mi>
            u 
          </mi> 
          <mi>
            i 
          </mi> 
         </msub> 
        </mrow> 
        <mo>
          ) 
        </mo> 
       </mrow> 
      </mrow> 
     </math> indicates the degree of membership of 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <msub> 
        <mi>
          u 
        </mi> 
        <mi>
          i 
        </mi> 
       </msub> 
      </mrow> 
     </math> in 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
        A 
      </mi> 
     </math>, where 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <msub> 
        <mi>
          f 
        </mi> 
        <mi>
          A 
        </mi> 
       </msub> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mrow> 
         <msub> 
          <mi>
            u 
          </mi> 
          <mi>
            i 
          </mi> 
         </msub> 
        </mrow> 
        <mo>
          ) 
        </mo> 
       </mrow> 
       <mo>
         ∈ 
       </mo> 
       <mrow> 
        <mo>
          [ 
        </mo> 
        <mrow> 
         <mn>
           0 
         </mn> 
         <mo>
           , 
         </mo> 
         <mn>
           1 
         </mn> 
        </mrow> 
        <mo>
          ] 
        </mo> 
       </mrow> 
      </mrow> 
     </math> and 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mn>
         1 
       </mn> 
       <mo>
         ≤ 
       </mo> 
       <mi>
         i 
       </mi> 
       <mo>
         ≤ 
       </mo> 
       <mi>
         n 
       </mi> 
      </mrow> 
     </math>.</p>
    <p>The Equations (1) and (2) presented define key concepts in fuzzy time series. Equation (1) establishes the universe of discourse 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
        U 
      </mi> 
     </math>, which represents the set of possible values in the time series. Equation (2) then defines a fuzzy set 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
        A 
      </mi> 
     </math> over 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
        U 
      </mi> 
     </math>, where each element 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <msub> 
        <mi>
          u 
        </mi> 
        <mi>
          i 
        </mi> 
       </msub> 
      </mrow> 
     </math> is assigned a degree of membership 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <msub> 
        <mi>
          f 
        </mi> 
        <mi>
          A 
        </mi> 
       </msub> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mrow> 
         <msub> 
          <mi>
            u 
          </mi> 
          <mi>
            i 
          </mi> 
         </msub> 
        </mrow> 
        <mo>
          ) 
        </mo> 
       </mrow> 
      </mrow> 
     </math> within the interval 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mrow> 
        <mo>
          [ 
        </mo> 
        <mrow> 
         <mn>
           0 
         </mn> 
         <mo>
           , 
         </mo> 
         <mn>
           1 
         </mn> 
        </mrow> 
        <mo>
          ] 
        </mo> 
       </mrow> 
      </mrow> 
     </math>, as determined by the membership function 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <msub> 
        <mi>
          f 
        </mi> 
        <mi>
          A 
        </mi> 
       </msub> 
      </mrow> 
     </math>. These fuzzy sets serve as the foundation for defining a fuzzy time series, which, unlike conventional time series composed of precise numerical values, consists of fuzzy sets representing linguistic variables. The definitions provided further formalize fuzzy time series by describing their structure and classification, distinguishing between time-invariant and time-variant cases based on how values evolve over time.</p>
    <p>The background definitions of fuzzy time series can be reviewed as follows.</p>
    <p>Definition 2.1 <xref ref-type="bibr" rid="scirp.142617-14">
      [14]
     </xref>: Let 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         Y 
       </mi> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mi>
          t 
        </mi> 
        <mo>
          ) 
        </mo> 
       </mrow> 
      </mrow> 
     </math> 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mrow> 
         <mi>
           t 
         </mi> 
         <mo>
           = 
         </mo> 
         <mn>
           0 
         </mn> 
         <mo>
           , 
         </mo> 
         <mn>
           1 
         </mn> 
         <mo>
           , 
         </mo> 
         <mn>
           2 
         </mn> 
         <mo>
           , 
         </mo> 
         <mo>
           ⋯ 
         </mo> 
        </mrow> 
        <mo>
          ) 
        </mo> 
       </mrow> 
      </mrow> 
     </math>, a subset of 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
        ℝ 
      </mi> 
     </math>, be the universe of discourse on which fuzzy sets 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <msub> 
        <mi>
          f 
        </mi> 
        <mi>
          i 
        </mi> 
       </msub> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mi>
          t 
        </mi> 
        <mo>
          ) 
        </mo> 
       </mrow> 
      </mrow> 
     </math> 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mrow> 
         <mi>
           i 
         </mi> 
         <mo>
           = 
         </mo> 
         <mn>
           1 
         </mn> 
         <mo>
           , 
         </mo> 
         <mn>
           2 
         </mn> 
         <mo>
           , 
         </mo> 
         <mo>
           ⋯ 
         </mo> 
        </mrow> 
        <mo>
          ) 
        </mo> 
       </mrow> 
      </mrow> 
     </math> are defined, and let 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         F 
       </mi> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mi>
          t 
        </mi> 
        <mo>
          ) 
        </mo> 
       </mrow> 
      </mrow> 
     </math> be a collection of 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <msub> 
        <mi>
          f 
        </mi> 
        <mi>
          i 
        </mi> 
       </msub> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mi>
          t 
        </mi> 
        <mo>
          ) 
        </mo> 
       </mrow> 
      </mrow> 
     </math> 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mrow> 
         <mi>
           i 
         </mi> 
         <mo>
           = 
         </mo> 
         <mn>
           1 
         </mn> 
         <mo>
           , 
         </mo> 
         <mn>
           2 
         </mn> 
         <mo>
           , 
         </mo> 
         <mo>
           ⋯ 
         </mo> 
        </mrow> 
        <mo>
          ) 
        </mo> 
       </mrow> 
      </mrow> 
     </math>. Then 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         F 
       </mi> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mi>
          t 
        </mi> 
        <mo>
          ) 
        </mo> 
       </mrow> 
      </mrow> 
     </math> is called a fuzzy time series on 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         Y 
       </mi> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mi>
          t 
        </mi> 
        <mo>
          ) 
        </mo> 
       </mrow> 
      </mrow> 
     </math> 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mrow> 
         <mi>
           t 
         </mi> 
         <mo>
           = 
         </mo> 
         <mn>
           0 
         </mn> 
         <mo>
           , 
         </mo> 
         <mn>
           1 
         </mn> 
         <mo>
           , 
         </mo> 
         <mn>
           2 
         </mn> 
         <mo>
           , 
         </mo> 
         <mo>
           ⋯ 
         </mo> 
        </mrow> 
        <mo>
          ) 
        </mo> 
       </mrow> 
      </mrow> 
     </math>.</p>
    <p>
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         F 
       </mi> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mi>
          t 
        </mi> 
        <mo>
          ) 
        </mo> 
       </mrow> 
      </mrow> 
     </math> can be regarded as a linguistic variable <xref ref-type="bibr" rid="scirp.142617-28">
      [28]
     </xref>, and 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <msub> 
        <mi>
          f 
        </mi> 
        <mi>
          i 
        </mi> 
       </msub> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mi>
          t 
        </mi> 
        <mo>
          ) 
        </mo> 
       </mrow> 
      </mrow> 
     </math> 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mrow> 
         <mi>
           i 
         </mi> 
         <mo>
           = 
         </mo> 
         <mn>
           1 
         </mn> 
         <mo>
           , 
         </mo> 
         <mn>
           2 
         </mn> 
         <mo>
           , 
         </mo> 
         <mo>
           ⋯ 
         </mo> 
        </mrow> 
        <mo>
          ) 
        </mo> 
       </mrow> 
      </mrow> 
     </math> can be viewed as possible linguistic values of 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         F 
       </mi> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mi>
          t 
        </mi> 
        <mo>
          ) 
        </mo> 
       </mrow> 
      </mrow> 
     </math> where 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <msub> 
        <mi>
          f 
        </mi> 
        <mi>
          i 
        </mi> 
       </msub> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mi>
          t 
        </mi> 
        <mo>
          ) 
        </mo> 
       </mrow> 
      </mrow> 
     </math> 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mrow> 
         <mi>
           i 
         </mi> 
         <mo>
           = 
         </mo> 
         <mn>
           1 
         </mn> 
         <mo>
           , 
         </mo> 
         <mn>
           2 
         </mn> 
         <mo>
           , 
         </mo> 
         <mo>
           ⋯ 
         </mo> 
        </mrow> 
        <mo>
          ) 
        </mo> 
       </mrow> 
      </mrow> 
     </math> are represented by fuzzy sets. Note that 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         F 
       </mi> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mi>
          t 
        </mi> 
        <mo>
          ) 
        </mo> 
       </mrow> 
      </mrow> 
     </math> is a function of time since its values can be different at different times. According to <xref ref-type="bibr" rid="scirp.142617-27">
      [27]
     </xref>, if 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         F 
       </mi> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mi>
          t 
        </mi> 
        <mo>
          ) 
        </mo> 
       </mrow> 
      </mrow> 
     </math> is caused by 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         F 
       </mi> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mrow> 
         <mi>
           t 
         </mi> 
         <mo>
           − 
         </mo> 
         <mn>
           1 
         </mn> 
        </mrow> 
        <mo>
          ) 
        </mo> 
       </mrow> 
      </mrow> 
     </math> only, then this relationship is represented by 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         F 
       </mi> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mrow> 
         <mi>
           t 
         </mi> 
         <mo>
           − 
         </mo> 
         <mn>
           1 
         </mn> 
        </mrow> 
        <mo>
          ) 
        </mo> 
       </mrow> 
       <mo>
         → 
       </mo> 
       <mi>
         F 
       </mi> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mi>
          t 
        </mi> 
        <mo>
          ) 
        </mo> 
       </mrow> 
      </mrow> 
     </math>.</p>
    <p>Definition 2.2 <xref ref-type="bibr" rid="scirp.142617-3">
      [3]
     </xref>: Let 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         F 
       </mi> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mi>
          t 
        </mi> 
        <mo>
          ) 
        </mo> 
       </mrow> 
      </mrow> 
     </math> be a fuzzy time series. If for any time 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
        t 
      </mi> 
     </math>, a displacement at 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
        t 
      </mi> 
     </math> causes a displacement at 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         F 
       </mi> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mi>
          t 
        </mi> 
        <mo>
          ) 
        </mo> 
       </mrow> 
      </mrow> 
     </math> and 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         F 
       </mi> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mi>
          t 
        </mi> 
        <mo>
          ) 
        </mo> 
       </mrow> 
      </mrow> 
     </math> only has finite elements, then 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         F 
       </mi> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mi>
          t 
        </mi> 
        <mo>
          ) 
        </mo> 
       </mrow> 
      </mrow> 
     </math> is called a time-invariant fuzzy time series. Otherwise, it is called a time-variant fuzzy time series.</p>
    <p>The above definitions will be used throughout the paper.</p>
   </sec>
   <sec id="s3_2">
    <title>3.2. Red-Black Tree</title>
    <p>A Red-Black tree is a self-balancing binary search tree that ensures balance by performing rotations and recoloring of nodes, following specific rules <xref ref-type="bibr" rid="scirp.142617-13">
      [13]
     </xref>. The relevance of this data structure can be observed in the work developed by <xref ref-type="bibr" rid="scirp.142617-29">
      [29]
     </xref>, where a concurrent RBT version is presented. In this paper, we focus only on the insertion function, which proceeds as follows:</p>
    <p>1) If the tree is empty, create a new node as the root and color it black.</p>
    <p>2) If the tree is not empty, insert the new node as a red leaf.</p>
    <p>3) If the parent of the new node is black, no further action is needed, and the insertion is complete.</p>
    <p>4) If the parent of the new node is red, check the color of the parent’s sibling (the new node’s “uncle”):</p>
    <p>*If the uncle is black or absent, perform a suitable rotation and recolor the nodes to restore balance.</p>
    <p>*If the uncle is red, recolor both the parent and the uncle to black, and check whether the grandparent (parent of the new node’s parent) is not the root. If the grandparent is not the root, recolor it and recheck for any red-red conflicts, treating the grandparent as the new node.</p>
   </sec>
  </sec><sec id="s4">
   <title>4. Fuzzy Model Based on Red-Black Tree</title>
   <p>This section outlines the structure and implementation details of the proposed fuzzy model. The diagram of the model is shown in <xref ref-type="fig" rid="fig1">
     Figure 1
    </xref>, followed by an explanation of each phase. The algorithm’s flow is depicted in <xref ref-type="fig" rid="fig2">
     Figure 2
    </xref>.</p>
   <p>The core script (main.m) initializes the variables and calls the fuzzyoutOfSample function. This function then calls additional functions responsible for constructing the tree, recoloring the nodes, and generating the clusters. The function RedBlackTree handles the tree construction, while TCARtree creates the matrix representation of the Red-Black Tree. Fuzzification and defuzzification are carried out by the FuzzyRBTModel function, which generates clusters and performs forecasts, returning the results to fuzzyoutOfSample.</p>
   <sec id="s4_1">
    <title>Step 1: Retrieve Stock Index Data</title>
    <p>In this step, stock index data is collected. The dataset should consist of a time series representing the closing prices of an index or stock. For the examples in this paper, the data was sourced from historical records on the <xref ref-type="bibr" rid="scirp.142617-http://www.investing.com">
      http://www.investing.com
     </xref> website, which is widely trusted by traders for its accurate stock market information.</p>
    <fig id="fig1" position="float">
     <label>Figure 1</label>
     <caption>
      <title>Figure 1. Structure of the proposed fuzzy model based on red-black trees.</title>
     </caption>
     <graphic mimetype="image" position="float" xlink:type="simple" xlink:href="https://html.scirp.org/file/1733069-rId109.jpeg?20250516112555" />
    </fig>
    <fig id="fig2" position="float">
     <label>Figure 2</label>
     <caption>
      <title>Figure 2. Flowchart of the implemented algorithm.</title>
     </caption>
     <graphic mimetype="image" position="float" xlink:type="simple" xlink:href="https://html.scirp.org/file/1733069-rId110.jpeg?20250516112555" />
    </fig>
    <p>The time series data is input into the model in array format, as shown in Equation (3):</p>
    <p>
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         x 
       </mi> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mi>
          t 
        </mi> 
        <mo>
          ) 
        </mo> 
       </mrow> 
       <mo>
         = 
       </mo> 
       <mrow> 
        <mo>
          { 
        </mo> 
        <mrow> 
         <msub> 
          <mi>
            x 
          </mi> 
          <mn>
            1 
          </mn> 
         </msub> 
         <mo>
           , 
         </mo> 
         <msub> 
          <mi>
            x 
          </mi> 
          <mn>
            2 
          </mn> 
         </msub> 
         <mo>
           , 
         </mo> 
         <mo>
           ⋯ 
         </mo> 
         <mo>
           , 
         </mo> 
         <msub> 
          <mi>
            x 
          </mi> 
          <mi>
            n 
          </mi> 
         </msub> 
        </mrow> 
        <mo>
          } 
        </mo> 
       </mrow> 
      </mrow> 
     </math> (3)</p>
    <p>In Equation (3), 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
        t 
      </mi> 
     </math> is the time index, where 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <msub> 
        <mi>
          x 
        </mi> 
        <mn>
          1 
        </mn> 
       </msub> 
      </mrow> 
     </math> is the first value and 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <msub> 
        <mi>
          x 
        </mi> 
        <mi>
          n 
        </mi> 
       </msub> 
      </mrow> 
     </math> is the last.</p>
   </sec>
   <sec id="s4_2">
    <title>Step 2: Remove Duplicates from Data for Tree Construction</title>
    <p>In this step, a new array is created from the time series, where duplicate elements are removed, resulting in 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <msub> 
        <mi>
          x 
        </mi> 
        <mi>
          u 
        </mi> 
       </msub> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mi>
          t 
        </mi> 
        <mo>
          ) 
        </mo> 
       </mrow> 
      </mrow> 
     </math>. This step is crucial for the subsequent red-black tree construction.</p>
   </sec>
   <sec id="s4_3">
    <title>Step 3: Build Red-Black Tree Structure</title>
    <p>Here, the red-black tree is built from the array 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <msub> 
        <mi>
          x 
        </mi> 
        <mi>
          u 
        </mi> 
       </msub> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mi>
          t 
        </mi> 
        <mo>
          ) 
        </mo> 
       </mrow> 
      </mrow> 
     </math>, ensuring that no duplicate nodes are included, as required by the model. A detailed example of constructing a red-black tree is provided in <xref ref-type="bibr" rid="scirp.142617-30">
      [30]
     </xref>.</p>
    <p>For example, given the following time series:</p>
    <p>
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         x 
       </mi> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mi>
          t 
        </mi> 
        <mo>
          ) 
        </mo> 
       </mrow> 
       <mo>
         = 
       </mo> 
       <mrow> 
        <mo>
          { 
        </mo> 
        <mrow> 
         <mn>
           6 
         </mn> 
         <mo>
           , 
         </mo> 
         <mn>
           7 
         </mn> 
         <mo>
           , 
         </mo> 
         <mn>
           15 
         </mn> 
         <mo>
           , 
         </mo> 
         <mn>
           7 
         </mn> 
         <mo>
           , 
         </mo> 
         <mn>
           10 
         </mn> 
         <mo>
           , 
         </mo> 
         <mn>
           2 
         </mn> 
         <mo>
           , 
         </mo> 
         <mn>
           8 
         </mn> 
         <mo>
           , 
         </mo> 
         <mn>
           20 
         </mn> 
         <mo>
           , 
         </mo> 
         <mn>
           5 
         </mn> 
        </mrow> 
        <mo>
          } 
        </mo> 
       </mrow> 
      </mrow> 
     </math> (4)</p>
    <p>After constructing the red-black tree from the data in Equation (4), the resulting structure is shown in <xref ref-type="fig" rid="fig3">
      Figure 3
     </xref>.</p>
    <fig id="fig3" position="float">
     <label>Figure 3</label>
     <caption>
      <title>Figure 3. Example of a red-black tree.</title>
     </caption>
     <graphic mimetype="image" position="float" xlink:type="simple" xlink:href="https://html.scirp.org/file/1733069-rId125.jpeg?20250516112556" />
    </fig>
   </sec>
   <sec id="s4_4">
    <title>Step 4: Cluster Generation</title>
    <p>In this step, clusters are generated to define fuzzy sets, with each cluster corresponding to a distinct fuzzy set.</p>
    <p>The clustering procedure is based on the parent-child difference in node values. Its advantages stem from ensuring that similar values are grouped within the same cluster. This way, the clusters maintain elements with values that preserve closer statistical measurements. Additionally, since the method relies on differences rather than absolute values, it is resistant to global shifts or biases in the data. Finally, it is also advantageous because it reduces noise in the data, provided there is a trend in the related values.</p>
    <p>The clustering algorithm follows these steps:</p>
    <p>For the tree shown in <xref ref-type="fig" rid="fig3">
      Figure 3
     </xref>, the clusters formed are as follows:</p>
   </sec>
   <sec id="s4_5">
    <title>Step 5: Fuzzification of Time Series</title>
    <p>Fuzzification refers to the process of converting the time series, which consists of real numbers ( 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <msub> 
        <mi>
          x 
        </mi> 
        <mn>
          1 
        </mn> 
       </msub> 
       <mo>
         , 
       </mo> 
       <msub> 
        <mi>
          x 
        </mi> 
        <mn>
          2 
        </mn> 
       </msub> 
       <mo>
         , 
       </mo> 
       <mo>
         ⋯ 
       </mo> 
       <mo>
         , 
       </mo> 
       <msub> 
        <mi>
          x 
        </mi> 
        <mi>
          n 
        </mi> 
       </msub> 
      </mrow> 
     </math>), into a fuzzy time series composed of fuzzy sets ( 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <msub> 
        <mi>
          A 
        </mi> 
        <mn>
          1 
        </mn> 
       </msub> 
       <mo>
         , 
       </mo> 
       <msub> 
        <mi>
          A 
        </mi> 
        <mn>
          2 
        </mn> 
       </msub> 
       <mo>
         , 
       </mo> 
       <mo>
         ⋯ 
       </mo> 
       <mo>
         , 
       </mo> 
       <msub> 
        <mi>
          A 
        </mi> 
        <mi>
          c 
        </mi> 
       </msub> 
      </mrow> 
     </math>). Here, 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
        n 
      </mi> 
     </math> is the number of time series elements, and 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
        c 
      </mi> 
     </math> is the number of fuzzy sets (which is equal to the number of clusters from Step 4). In this example, 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         n 
       </mi> 
       <mo>
         = 
       </mo> 
       <mn>
         9 
       </mn> 
      </mrow> 
     </math> and 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         c 
       </mi> 
       <mo>
         = 
       </mo> 
       <mn>
         4 
       </mn> 
      </mrow> 
     </math>.</p>
    <p>The fuzzification process is as follows:</p>
    <p>The result of this process is a fuzzy time series, as shown in <xref ref-type="table" rid="table1">
      Table 1
     </xref>.</p>
    <table-wrap id="table1">
     <label>
      <xref ref-type="table" rid="table1">
       Table 1
      </xref></label>
     <caption>
      <title>
       <xref ref-type="bibr" rid="scirp.142617-"></xref>Table 1. Example of fuzzification: The second column represents the fuzzy time series, denoted as 

       <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
  
         <mi>
          
   A
  
         </mi>
  
         <mrow>
   
          <mo>
           
    (
   
          </mo> 
   
          <mi>
           
    t
   
          </mi> 
   
          <mo>
           
    )
   
          </mo>
  
         </mrow>
 
        </mrow>

       </math>.</title>
     </caption>
     <table class="MsoTableGrid custom-table" border="0" cellspacing="0" cellpadding="0"> 
      <tr> 
       <td class="custom-bottom-td custom-top-td acenter" width="50.00%"><p style="text-align:center">Time Series</p></td> 
       <td class="custom-bottom-td custom-top-td acenter" width="50.00%"><p style="text-align:center">Fuzzy Time Series</p></td> 
      </tr> 
      <tr> 
       <td class="custom-top-td acenter" width="50.00%"><p style="text-align:center">6</p></td> 
       <td class="custom-top-td acenter" width="50.00%"><p style="text-align:center">A1</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="50.00%"><p style="text-align:center">7</p></td> 
       <td class="acenter" width="50.00%"><p style="text-align:center">A1</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="50.00%"><p style="text-align:center">15</p></td> 
       <td class="acenter" width="50.00%"><p style="text-align:center">A4</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="50.00%"><p style="text-align:center">7</p></td> 
       <td class="acenter" width="50.00%"><p style="text-align:center">A1</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="50.00%"><p style="text-align:center">10</p></td> 
       <td class="acenter" width="50.00%"><p style="text-align:center">A2</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="50.00%"><p style="text-align:center">2</p></td> 
       <td class="acenter" width="50.00%"><p style="text-align:center">A3</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="50.00%"><p style="text-align:center">8</p></td> 
       <td class="acenter" width="50.00%"><p style="text-align:center">A2</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="50.00%"><p style="text-align:center">20</p></td> 
       <td class="acenter" width="50.00%"><p style="text-align:center">A4</p></td> 
      </tr> 
      <tr> 
       <td class="custom-bottom-td acenter" width="50.00%"><p style="text-align:center">5</p></td> 
       <td class="custom-bottom-td acenter" width="50.00%"><p style="text-align:center">A1</p></td> 
      </tr> 
     </table>
    </table-wrap>
   </sec>
   <sec id="s4_6">
    <title>Step 6: Creation of Fuzzy Group Rules</title>
    <p>In this step, fuzzy rules are created based on the fuzzy time series. A typical fuzzy dependency rule is represented as:</p>
    <p>
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         A 
       </mi> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mi>
          t 
        </mi> 
        <mo>
          ) 
        </mo> 
       </mrow> 
       <mo>
         → 
       </mo> 
       <mi>
         A 
       </mi> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mrow> 
         <mi>
           t 
         </mi> 
         <mo>
           + 
         </mo> 
         <mn>
           1 
         </mn> 
        </mrow> 
        <mo>
          ) 
        </mo> 
       </mrow> 
      </mrow> 
     </math> (5)</p>
    <p>here, 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         A 
       </mi> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mi>
          t 
        </mi> 
        <mo>
          ) 
        </mo> 
       </mrow> 
      </mrow> 
     </math> is the antecedent (precedent) and 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         A 
       </mi> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mrow> 
         <mi>
           t 
         </mi> 
         <mo>
           + 
         </mo> 
         <mn>
           1 
         </mn> 
        </mrow> 
        <mo>
          ) 
        </mo> 
       </mrow> 
      </mrow> 
     </math> is the consequent.</p>
    <p>For each fuzzy time series value, a rule is generated to predict the next fuzzy time series value. For example, if the first fuzzy time series value is A1 (corresponding to the original time series value of 6), this implies the next fuzzy time series value will also be A1 (corresponding to 7 in the original time series).</p>
    <p>The fuzzy rules corresponding to the fuzzy time series from Equation (4) are shown in <xref ref-type="table" rid="table2">
      Table 2
     </xref>.</p>
    <table-wrap id="table2">
     <label>
      <xref ref-type="table" rid="table2">
       Table 2
      </xref></label>
     <caption>
      <title>
       <xref ref-type="bibr" rid="scirp.142617-"></xref>Table 2. Fuzzy rules derived from the fuzzy time series.</title>
     </caption>
     <table class="MsoTableGrid custom-table" border="0" cellspacing="0" cellpadding="0"> 
      <tr> 
       <td class="custom-bottom-td custom-top-td acenter" width="19.99%"><p style="text-align:center">Time Series (t)</p></td> 
       <td class="custom-bottom-td custom-top-td acenter" width="20.00%"><p style="text-align:center">Time Series (t + 1)</p></td> 
       <td class="custom-bottom-td custom-top-td acenter" width="20.00%"><p style="text-align:center">Fuzzy Time Series</p></td> 
       <td class="custom-bottom-td custom-top-td acenter" width="20.00%"><p style="text-align:center">Fuzzy Time Series (t + 1)</p></td> 
       <td class="custom-bottom-td custom-top-td acenter" width="20.00%"><p style="text-align:center">Fuzzy Rule</p></td> 
      </tr> 
      <tr> 
       <td class="custom-top-td acenter" width="19.99%"><p style="text-align:center">6</p></td> 
       <td class="custom-top-td acenter" width="20.00%"><p style="text-align:center">7</p></td> 
       <td class="custom-top-td acenter" width="20.00%"><p style="text-align:center">A1</p></td> 
       <td class="custom-top-td acenter" width="20.00%"><p style="text-align:center">A1</p></td> 
       <td class="custom-top-td acenter" width="20.00%"><p style="text-align:center">A1→A1</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="19.99%"><p style="text-align:center">7</p></td> 
       <td class="acenter" width="20.00%"><p style="text-align:center">15</p></td> 
       <td class="acenter" width="20.00%"><p style="text-align:center">A1</p></td> 
       <td class="acenter" width="20.00%"><p style="text-align:center">A4</p></td> 
       <td class="acenter" width="20.00%"><p style="text-align:center">A1→A4</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="19.99%"><p style="text-align:center">15</p></td> 
       <td class="acenter" width="20.00%"><p style="text-align:center">7</p></td> 
       <td class="acenter" width="20.00%"><p style="text-align:center">A4</p></td> 
       <td class="acenter" width="20.00%"><p style="text-align:center">A1</p></td> 
       <td class="acenter" width="20.00%"><p style="text-align:center">A4→A1</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="19.99%"><p style="text-align:center">7</p></td> 
       <td class="acenter" width="20.00%"><p style="text-align:center">10</p></td> 
       <td class="acenter" width="20.00%"><p style="text-align:center">A1</p></td> 
       <td class="acenter" width="20.00%"><p style="text-align:center">A2</p></td> 
       <td class="acenter" width="20.00%"><p style="text-align:center">A1→A2</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="19.99%"><p style="text-align:center">10</p></td> 
       <td class="acenter" width="20.00%"><p style="text-align:center">2</p></td> 
       <td class="acenter" width="20.00%"><p style="text-align:center">A2</p></td> 
       <td class="acenter" width="20.00%"><p style="text-align:center">A3</p></td> 
       <td class="acenter" width="20.00%"><p style="text-align:center">A2→A3</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="19.99%"><p style="text-align:center">2</p></td> 
       <td class="acenter" width="20.00%"><p style="text-align:center">8</p></td> 
       <td class="acenter" width="20.00%"><p style="text-align:center">A3</p></td> 
       <td class="acenter" width="20.00%"><p style="text-align:center">A2</p></td> 
       <td class="acenter" width="20.00%"><p style="text-align:center">A3→A2</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="19.99%"><p style="text-align:center">8</p></td> 
       <td class="acenter" width="20.00%"><p style="text-align:center">20</p></td> 
       <td class="acenter" width="20.00%"><p style="text-align:center">A2</p></td> 
       <td class="acenter" width="20.00%"><p style="text-align:center">A4</p></td> 
       <td class="acenter" width="20.00%"><p style="text-align:center">A2→A4</p></td> 
      </tr> 
      <tr> 
       <td class="custom-bottom-td acenter" width="19.99%"><p style="text-align:center">20</p></td> 
       <td class="custom-bottom-td acenter" width="20.00%"><p style="text-align:center">5</p></td> 
       <td class="custom-bottom-td acenter" width="20.00%"><p style="text-align:center">A4</p></td> 
       <td class="custom-bottom-td acenter" width="20.00%"><p style="text-align:center">A1</p></td> 
       <td class="custom-bottom-td acenter" width="20.00%"><p style="text-align:center">A4→A1</p></td> 
      </tr> 
     </table>
    </table-wrap>
    <p>Next, fuzzy rules are grouped. If multiple rules share the same antecedent, they are combined into a single group rule with the common antecedent and all their consequents. For instance, the following rules</p>
    <p>
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mtable columnalign="left"> 
       <mtr> 
        <mtd> 
         <mi>
           A 
         </mi> 
         <mn>
           1 
         </mn> 
         <mo>
           → 
         </mo> 
         <mi>
           A 
         </mi> 
         <mn>
           1 
         </mn> 
        </mtd> 
       </mtr> 
       <mtr> 
        <mtd> 
         <mi>
           A 
         </mi> 
         <mn>
           1 
         </mn> 
         <mo>
           → 
         </mo> 
         <mi>
           A 
         </mi> 
         <mn>
           2 
         </mn> 
        </mtd> 
       </mtr> 
       <mtr> 
        <mtd> 
         <mi>
           A 
         </mi> 
         <mn>
           1 
         </mn> 
         <mo>
           → 
         </mo> 
         <mi>
           A 
         </mi> 
         <mn>
           7 
         </mn> 
        </mtd> 
       </mtr> 
      </mtable> 
     </math> (6)</p>
    <p>can be grouped as:</p>
    <p>
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         A 
       </mi> 
       <mn>
         1 
       </mn> 
       <mo>
         → 
       </mo> 
       <mi>
         A 
       </mi> 
       <mn>
         1 
       </mn> 
       <mo>
         , 
       </mo> 
       <mi>
         A 
       </mi> 
       <mn>
         2 
       </mn> 
       <mo>
         , 
       </mo> 
       <mi>
         A 
       </mi> 
       <mn>
         7 
       </mn> 
      </mrow> 
     </math> (7)</p>
    <p>
     <xref ref-type="table" rid="table3">
      Table 3
     </xref> shows the fuzzy group rules (FGRs) derived from <xref ref-type="table" rid="table2">
      Table 2
     </xref>. Note that the fuzzy group rules include all consequents, even when repeated.</p>
    <table-wrap id="table3">
     <label>
      <xref ref-type="table" rid="table3">
       Table 3
      </xref></label>
     <caption>
      <title>
       <xref ref-type="bibr" rid="scirp.142617-"></xref>Table 3. Generated fuzzy group rules.</title>
     </caption>
     <table class="MsoTableGrid custom-table" border="0" cellspacing="0" cellpadding="0"> 
      <tr> 
       <td class="custom-bottom-td custom-top-td acenter" width="100.00%"><p style="text-align:center">Fuzzy Group Rules</p></td> 
      </tr> 
      <tr> 
       <td class="custom-top-td acenter" width="100.00%"><p style="text-align:center">A1→A1, A4, A2</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="100.00%"><p style="text-align:center">A2→A3, A4</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="100.00%"><p style="text-align:center">A3→A2</p></td> 
      </tr> 
      <tr> 
       <td class="custom-bottom-td acenter" width="100.00%"><p style="text-align:center">A4→A1, A1</p></td> 
      </tr> 
     </table>
    </table-wrap>
   </sec>
   <sec id="s4_7">
    <title>Step 7: Linguistic Forecasting</title>
    <p>In this step, linguistic forecasting is performed using the fuzzy group rules (FGRs) from Step 6. Given the fuzzy time series 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         A 
       </mi> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mi>
          t 
        </mi> 
        <mo>
          ) 
        </mo> 
       </mrow> 
      </mrow> 
     </math>, the forecast for the next time step is obtained by applying the appropriate fuzzy rule.</p>
    <p>For example, consider the fuzzy time series from Equation (8):</p>
    <p>
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         A 
       </mi> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mi>
          t 
        </mi> 
        <mo>
          ) 
        </mo> 
       </mrow> 
       <mo>
         = 
       </mo> 
       <mi>
         A 
       </mi> 
       <mn>
         1 
       </mn> 
       <mo>
         , 
       </mo> 
       <mi>
         A 
       </mi> 
       <mn>
         1 
       </mn> 
       <mo>
         , 
       </mo> 
       <mi>
         A 
       </mi> 
       <mn>
         4 
       </mn> 
       <mo>
         , 
       </mo> 
       <mi>
         A 
       </mi> 
       <mn>
         1 
       </mn> 
       <mo>
         , 
       </mo> 
       <mi>
         A 
       </mi> 
       <mn>
         2 
       </mn> 
       <mo>
         , 
       </mo> 
       <mi>
         A 
       </mi> 
       <mn>
         3 
       </mn> 
       <mo>
         , 
       </mo> 
       <mi>
         A 
       </mi> 
       <mn>
         2 
       </mn> 
       <mo>
         , 
       </mo> 
       <mi>
         A 
       </mi> 
       <mn>
         4 
       </mn> 
       <mo>
         , 
       </mo> 
       <mi>
         A 
       </mi> 
       <mn>
         1 
       </mn> 
      </mrow> 
     </math> (8)</p>
    <p>To forecast the second sample, we first identify the fuzzy value for 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         t 
       </mi> 
       <mo>
         = 
       </mo> 
       <mn>
         1 
       </mn> 
      </mrow> 
     </math>, which is 
     <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         A 
       </mi> 
       <mn>
         1 
       </mn> 
      </mrow> 
     </math>. Referring to the FGRs in <xref ref-type="table" rid="table3">
      Table 3
     </xref>, the corresponding rule is 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         A 
       </mi> 
       <mn>
         1 
       </mn> 
       <mo>
         → 
       </mo> 
       <mi>
         A 
       </mi> 
       <mn>
         1 
       </mn> 
       <mo>
         , 
       </mo> 
       <mi>
         A 
       </mi> 
       <mn>
         4 
       </mn> 
       <mo>
         , 
       </mo> 
       <mi>
         A 
       </mi> 
       <mn>
         2 
       </mn> 
      </mrow> 
     </math>. Thus, the forecast for 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         t 
       </mi> 
       <mo>
         = 
       </mo> 
       <mn>
         2 
       </mn> 
      </mrow> 
     </math> is 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         A 
       </mi> 
       <mn>
         1 
       </mn> 
       <mo>
         , 
       </mo> 
       <mi>
         A 
       </mi> 
       <mn>
         4 
       </mn> 
       <mo>
         , 
       </mo> 
       <mi>
         A 
       </mi> 
       <mn>
         2 
       </mn> 
      </mrow> 
     </math>.</p>
   </sec>
   <sec id="s4_8">
    <title>Step 8: Defuzzification for Numerical Forecasts</title>
    <p>In the final step, the linguistic forecast is converted back to a numerical value using defuzzification. To explain this, consider the fuzzy forecast for the second sample, as shown in Equation (9):</p>
    <p>
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mtext>
         fuzzy_forecast 
       </mtext> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mn>
          2 
        </mn> 
        <mo>
          ) 
        </mo> 
       </mrow> 
       <mo>
         = 
       </mo> 
       <mrow> 
        <mo>
          { 
        </mo> 
        <mrow> 
         <mi>
           A 
         </mi> 
         <mn>
           1 
         </mn> 
         <mo>
           , 
         </mo> 
         <mi>
           A 
         </mi> 
         <mn>
           4 
         </mn> 
         <mo>
           , 
         </mo> 
         <mi>
           A 
         </mi> 
         <mn>
           2 
         </mn> 
        </mrow> 
        <mo>
          } 
        </mo> 
       </mrow> 
      </mrow> 
     </math> (9)</p>
    <p>Each forecast set is assigned a weight, as shown in <xref ref-type="table" rid="table4">
      Table 4
     </xref>.</p>
    <table-wrap id="table4">
     <label>
      <xref ref-type="table" rid="table4">
       Table 4
      </xref></label>
     <caption>
      <title>
       <xref ref-type="bibr" rid="scirp.142617-"></xref>Table 4. Weights assigned to each forecast set.</title>
     </caption>
     <table class="MsoTableGrid custom-table" border="0" cellspacing="0" cellpadding="0"> 
      <tr> 
       <td class="custom-bottom-td custom-top-td acenter" width="50.00%"><p style="text-align:center">Forecast Sets</p></td> 
       <td class="custom-bottom-td custom-top-td acenter" width="50.00%"><p style="text-align:center">Weights</p></td> 
      </tr> 
      <tr> 
       <td class="custom-top-td acenter" width="50.00%"><p style="text-align:center">A1</p></td> 
       <td class="custom-top-td acenter" width="50.00%"><p style="text-align:center">1</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="50.00%"><p style="text-align:center">A4</p></td> 
       <td class="acenter" width="50.00%"><p style="text-align:center">2</p></td> 
      </tr> 
      <tr> 
       <td class="custom-bottom-td acenter" width="50.00%"><p style="text-align:center">A2</p></td> 
       <td class="custom-bottom-td acenter" width="50.00%"><p style="text-align:center">3</p></td> 
      </tr> 
     </table>
    </table-wrap>
    <p>Next, the average of each cluster center is computed, as shown in <xref ref-type="table" rid="table5">
      Table 5
     </xref>.</p>
    <table-wrap id="table5">
     <label>
      <xref ref-type="table" rid="table5">
       Table 5
      </xref></label>
     <caption>
      <title>
       <xref ref-type="bibr" rid="scirp.142617-"></xref>Table 5. Cluster centers and their averages.</title>
     </caption>
     <table class="MsoTableGrid custom-table" border="0" cellspacing="0" cellpadding="0"> 
      <tr> 
       <td class="custom-bottom-td custom-top-td acenter" width="22.61%"><p style="text-align:center">Cluster</p></td> 
       <td class="custom-bottom-td custom-top-td acenter" width="22.61%"><p style="text-align:center">Cluster center (average)</p></td> 
      </tr> 
      <tr> 
       <td class="custom-top-td acenter" width="22.61%"><p style="text-align:center">1</p></td> 
       <td class="custom-top-td acenter" width="22.61%"><p style="text-align:center">6</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="22.61%"><p style="text-align:center">2</p></td> 
       <td class="acenter" width="22.61%"><p style="text-align:center">9</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="22.61%"><p style="text-align:center">3</p></td> 
       <td class="acenter" width="22.61%"><p style="text-align:center">2</p></td> 
      </tr> 
      <tr> 
       <td class="custom-bottom-td acenter" width="22.61%"><p style="text-align:center">4</p></td> 
       <td class="custom-bottom-td acenter" width="22.61%"><p style="text-align:center">17.5</p></td> 
      </tr> 
     </table>
    </table-wrap>
    <p>Finally, the numerical forecast is computed as the weighted average of the cluster centers. For example, for the second sample, the forecast is:</p>
    <p>
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mtext>
         forecast 
       </mtext> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mn>
          2 
        </mn> 
        <mo>
          ) 
        </mo> 
       </mrow> 
       <mo>
         = 
       </mo> 
       <mfrac> 
        <mrow> 
         <mn>
           6 
         </mn> 
         <mo>
           × 
         </mo> 
         <mn>
           1 
         </mn> 
         <mo>
           + 
         </mo> 
         <mn>
           17.5 
         </mn> 
         <mo>
           × 
         </mo> 
         <mn>
           2 
         </mn> 
         <mo>
           + 
         </mo> 
         <mn>
           9 
         </mn> 
         <mo>
           × 
         </mo> 
         <mn>
           3 
         </mn> 
        </mrow> 
        <mrow> 
         <mn>
           1 
         </mn> 
         <mo>
           + 
         </mo> 
         <mn>
           2 
         </mn> 
         <mo>
           + 
         </mo> 
         <mn>
           3 
         </mn> 
        </mrow> 
       </mfrac> 
       <mo>
         = 
       </mo> 
       <mn>
         11.333 
       </mn> 
      </mrow> 
     </math> (10)</p>
    <p>This completes the process for forecasting subsequent samples. Note that Steps 1 through 6 represent the training phase, and Steps 7 and 8 are used repeatedly to make forecasts for future samples.</p>
   </sec>
  </sec><sec id="s5">
   <title>5. Performance and Application of the Proposed Model</title>
   <p>This section illustrates the proposed method using two distinct examples and compares its forecasting performance with that of four existing models from the literature: (CHEN, 1996) <xref ref-type="bibr" rid="scirp.142617-3">
     [3]
    </xref>, (YU, 2005) <xref ref-type="bibr" rid="scirp.142617-4">
     [4]
    </xref>, (TEOH et al., 2008) <xref ref-type="bibr" rid="scirp.142617-11">
     [11]
    </xref>, and (SINGH; DHIMAN; KAUR, 2018) <xref ref-type="bibr" rid="scirp.142617-10">
     [10]
    </xref>. The comparison involves using these models on the same dataset, and their forecasting results are compared with the proposed model.</p>
   <p>The models are evaluated using the following two performance metrics:</p>
   <p>The comparison between the models is based on the RMSE and RMSE relative to the naive model, as defined by the equations below.</p>
   <p>
    <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"> <mrow> 
      <msub> 
       <mrow> 
        <mtext>
          RMSE 
        </mtext> 
       </mrow> 
       <mrow> 
        <mtext>
          model 
        </mtext> 
       </mrow> 
      </msub> 
      <mo>
        = 
      </mo> 
      <msqrt> 
       <mrow> 
        <mfrac> 
         <mrow> 
          <msubsup> 
           <mstyle displaystyle="true" mathsize="140%"> 
            <mo>
              ∑ 
            </mo> 
           </mstyle> 
           <mrow> 
            <mi>
              k 
            </mi> 
            <mo>
              = 
            </mo> 
            <mn>
              1 
            </mn> 
           </mrow> 
           <mi>
             n 
           </mi> 
          </msubsup> 
          <msup> 
           <mrow> 
            <mrow> 
             <mo>
               ( 
             </mo> 
             <mrow> 
              <mi>
                y 
              </mi> 
              <mrow> 
               <mo>
                 ( 
               </mo> 
               <mi>
                 k 
               </mi> 
               <mo>
                 ) 
               </mo> 
              </mrow> 
              <mo>
                − 
              </mo> 
              <mover accent="true"> 
               <mi>
                 y 
               </mi> 
               <mo>
                 ^ 
               </mo> 
              </mover> 
              <mrow> 
               <mo>
                 ( 
               </mo> 
               <mi>
                 k 
               </mi> 
               <mo>
                 ) 
               </mo> 
              </mrow> 
             </mrow> 
             <mo>
               ) 
             </mo> 
            </mrow> 
           </mrow> 
           <mn>
             2 
           </mn> 
          </msup> 
         </mrow> 
         <mi>
           n 
         </mi> 
        </mfrac> 
       </mrow> 
      </msqrt> 
     </mrow> 
    </math> (11)</p>
   <p>
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
      <msub> 
       <mrow> 
        <mtext>
          RMSE 
        </mtext> 
       </mrow> 
       <mrow> 
        <mtext>
          relative_naive 
        </mtext> 
       </mrow> 
      </msub> 
      <mo>
        = 
      </mo> 
      <mfrac> 
       <mrow> 
        <msqrt> 
         <mrow> 
          <msubsup> 
           <mstyle displaystyle="true" mathsize="140%"> 
            <mo>
              ∑ 
            </mo> 
           </mstyle> 
           <mrow> 
            <mi>
              k 
            </mi> 
            <mo>
              = 
            </mo> 
            <mn>
              1 
            </mn> 
           </mrow> 
           <mi>
             n 
           </mi> 
          </msubsup> 
          <msup> 
           <mrow> 
            <mrow> 
             <mo>
               ( 
             </mo> 
             <mrow> 
              <mi>
                y 
              </mi> 
              <mrow> 
               <mo>
                 ( 
               </mo> 
               <mi>
                 k 
               </mi> 
               <mo>
                 ) 
               </mo> 
              </mrow> 
              <mo>
                − 
              </mo> 
              <mover accent="true"> 
               <mi>
                 y 
               </mi> 
               <mo>
                 ^ 
               </mo> 
              </mover> 
              <mrow> 
               <mo>
                 ( 
               </mo> 
               <mi>
                 k 
               </mi> 
               <mo>
                 ) 
               </mo> 
              </mrow> 
             </mrow> 
             <mo>
               ) 
             </mo> 
            </mrow> 
           </mrow> 
           <mn>
             2 
           </mn> 
          </msup> 
         </mrow> 
        </msqrt> 
       </mrow> 
       <mrow> 
        <msqrt> 
         <mrow> 
          <msubsup> 
           <mstyle displaystyle="true" mathsize="140%"> 
            <mo>
              ∑ 
            </mo> 
           </mstyle> 
           <mrow> 
            <mi>
              k 
            </mi> 
            <mo>
              = 
            </mo> 
            <mn>
              1 
            </mn> 
           </mrow> 
           <mi>
             n 
           </mi> 
          </msubsup> 
          <msup> 
           <mrow> 
            <mrow> 
             <mo>
               ( 
             </mo> 
             <mrow> 
              <mi>
                y 
              </mi> 
              <mrow> 
               <mo>
                 ( 
               </mo> 
               <mi>
                 k 
               </mi> 
               <mo>
                 ) 
               </mo> 
              </mrow> 
              <mo>
                − 
              </mo> 
              <msub> 
               <mover accent="true"> 
                <mi>
                  y 
                </mi> 
                <mo>
                  ^ 
                </mo> 
               </mover> 
               <mrow> 
                <mtext>
                  naive 
                </mtext> 
               </mrow> 
              </msub> 
              <mrow> 
               <mo>
                 ( 
               </mo> 
               <mi>
                 k 
               </mi> 
               <mo>
                 ) 
               </mo> 
              </mrow> 
             </mrow> 
             <mo>
               ) 
             </mo> 
            </mrow> 
           </mrow> 
           <mn>
             2 
           </mn> 
          </msup> 
         </mrow> 
        </msqrt> 
       </mrow> 
      </mfrac> 
     </mrow> 
    </math> (12)</p>
   <p>
    <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"> <mrow> 
      <msubsup> 
       <mtext>
         R 
       </mtext> 
       <mrow> 
        <mtext>
          model 
        </mtext> 
       </mrow> 
       <mtext>
         2 
       </mtext> 
      </msubsup> 
      <mo>
        = 
      </mo> 
      <mn>
        1 
      </mn> 
      <mo>
        − 
      </mo> 
      <mfrac> 
       <mrow> 
        <msubsup> 
         <mstyle displaystyle="true" mathsize="140%"> 
          <mo>
            ∑ 
          </mo> 
         </mstyle> 
         <mrow> 
          <mi>
            k 
          </mi> 
          <mo>
            = 
          </mo> 
          <mn>
            1 
          </mn> 
         </mrow> 
         <mi>
           n 
         </mi> 
        </msubsup> 
        <msup> 
         <mrow> 
          <mrow> 
           <mo>
             ( 
           </mo> 
           <mrow> 
            <mi>
              y 
            </mi> 
            <mrow> 
             <mo>
               ( 
             </mo> 
             <mi>
               k 
             </mi> 
             <mo>
               ) 
             </mo> 
            </mrow> 
            <mo>
              − 
            </mo> 
            <mover accent="true"> 
             <mi>
               y 
             </mi> 
             <mo>
               ^ 
             </mo> 
            </mover> 
            <mrow> 
             <mo>
               ( 
             </mo> 
             <mi>
               k 
             </mi> 
             <mo>
               ) 
             </mo> 
            </mrow> 
           </mrow> 
           <mo>
             ) 
           </mo> 
          </mrow> 
         </mrow> 
         <mn>
           2 
         </mn> 
        </msup> 
       </mrow> 
       <mrow> 
        <msubsup> 
         <mstyle displaystyle="true" mathsize="140%"> 
          <mo>
            ∑ 
          </mo> 
         </mstyle> 
         <mrow> 
          <mi>
            k 
          </mi> 
          <mo>
            = 
          </mo> 
          <mn>
            1 
          </mn> 
         </mrow> 
         <mi>
           n 
         </mi> 
        </msubsup> 
        <msup> 
         <mrow> 
          <mrow> 
           <mo>
             ( 
           </mo> 
           <mrow> 
            <mi>
              y 
            </mi> 
            <mrow> 
             <mo>
               ( 
             </mo> 
             <mi>
               k 
             </mi> 
             <mo>
               ) 
             </mo> 
            </mrow> 
            <mo>
              − 
            </mo> 
            <mover accent="true"> 
             <mi>
               y 
             </mi> 
             <mo>
               ¯ 
             </mo> 
            </mover> 
            <mrow> 
             <mo>
               ( 
             </mo> 
             <mi>
               k 
             </mi> 
             <mo>
               ) 
             </mo> 
            </mrow> 
           </mrow> 
           <mo>
             ) 
           </mo> 
          </mrow> 
         </mrow> 
         <mn>
           2 
         </mn> 
        </msup> 
       </mrow> 
      </mfrac> 
     </mrow> 
    </math> (13)</p>
   <p>
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
      <msub> 
       <mrow> 
        <mtext>
          MAE 
        </mtext> 
       </mrow> 
       <mrow> 
        <mtext>
          model 
        </mtext> 
       </mrow> 
      </msub> 
      <mo>
        = 
      </mo> 
      <mfrac> 
       <mrow> 
        <msubsup> 
         <mstyle displaystyle="true" mathsize="140%"> 
          <mo>
            ∑ 
          </mo> 
         </mstyle> 
         <mrow> 
          <mi>
            k 
          </mi> 
          <mo>
            = 
          </mo> 
          <mn>
            1 
          </mn> 
         </mrow> 
         <mi>
           n 
         </mi> 
        </msubsup> 
        <msup> 
         <mrow> 
          <mrow> 
           <mo>
             ( 
           </mo> 
           <mrow> 
            <mi>
              y 
            </mi> 
            <mrow> 
             <mo>
               ( 
             </mo> 
             <mi>
               k 
             </mi> 
             <mo>
               ) 
             </mo> 
            </mrow> 
            <mo>
              − 
            </mo> 
            <mover accent="true"> 
             <mi>
               y 
             </mi> 
             <mo>
               ^ 
             </mo> 
            </mover> 
            <mrow> 
             <mo>
               ( 
             </mo> 
             <mi>
               k 
             </mi> 
             <mo>
               ) 
             </mo> 
            </mrow> 
           </mrow> 
           <mo>
             ) 
           </mo> 
          </mrow> 
         </mrow> 
         <mn>
           2 
         </mn> 
        </msup> 
       </mrow> 
       <mi>
         n 
       </mi> 
      </mfrac> 
     </mrow> 
    </math> (14)</p>
   <p>In these equations, 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
      <mi>
        y 
      </mi> 
      <mrow> 
       <mo>
         ( 
       </mo> 
       <mi>
         k 
       </mi> 
       <mo>
         ) 
       </mo> 
      </mrow> 
     </mrow> 
    </math> refers to the actual observed value, 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
      <mover accent="true"> 
       <mi>
         y 
       </mi> 
       <mo>
         ^ 
       </mo> 
      </mover> 
      <mrow> 
       <mo>
         ( 
       </mo> 
       <mi>
         k 
       </mi> 
       <mo>
         ) 
       </mo> 
      </mrow> 
     </mrow> 
    </math> is the forecasted value by a specific model, and 
    <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
      <msub> 
       <mover accent="true"> 
        <mi>
          y 
        </mi> 
        <mo>
          ^ 
        </mo> 
       </mover> 
       <mrow> 
        <mtext>
          naive 
        </mtext> 
       </mrow> 
      </msub> 
      <mrow> 
       <mo>
         ( 
       </mo> 
       <mi>
         k 
       </mi> 
       <mo>
         ) 
       </mo> 
      </mrow> 
     </mrow> 
    </math> represents the forecasted value using the “naïve” approach.</p>
   <sec id="s5_1">
    <title>5.1. In-Sample Test</title>
    <p>The in-sample test was conducted using the closing prices of the Ibovespa (Brazilian stock index) from 03/29/2018 to 10/11/2018, obtained from <xref ref-type="bibr" rid="scirp.142617-http://investing.com/">
      http://investing.com/
     </xref>. A sample of the data used for the model forecasts is presented in <xref ref-type="table" rid="table6">
      Table 6
     </xref>.</p>
    <table-wrap id="table6">
     <label>
      <xref ref-type="table" rid="table6">
       Table 6
      </xref></label>
     <caption>
      <title>
       <xref ref-type="bibr" rid="scirp.142617-"></xref>Table 6. Ibovespa daily closing index data used for in-sample testing, showing forecasts from various models, including the proposed one.</title>
     </caption>
     <table class="MsoTableGrid custom-table" border="0" cellspacing="0" cellpadding="0"> 
      <tr> 
       <td class="custom-bottom-td custom-top-td acenter" width="14.38%"><p style="text-align:center">Date</p></td> 
       <td class="custom-bottom-td custom-top-td acenter" width="13.26%"><p style="text-align:center">Ibovespa</p><p style="text-align:center">Real Data</p></td> 
       <td class="custom-bottom-td custom-top-td acenter" width="11.56%"><p style="text-align:center">Chen</p><p style="text-align:center">1996</p></td> 
       <td class="custom-bottom-td custom-top-td acenter" width="11.56%"><p style="text-align:center">Yu</p><p style="text-align:center">2004</p></td> 
       <td class="custom-bottom-td custom-top-td acenter" width="11.56%"><p style="text-align:center">Teoh</p><p style="text-align:center">2008</p></td> 
       <td class="custom-bottom-td custom-top-td acenter" width="11.56%"><p style="text-align:center">Teoh</p><p style="text-align:center">2008</p></td> 
       <td class="custom-bottom-td custom-top-td acenter" width="12.54%"><p style="text-align:center">Tavares</p><p style="text-align:center">2022</p></td> 
       <td class="custom-bottom-td custom-top-td acenter" width="13.57%"><p style="text-align:center">Proposed</p><p style="text-align:center">Model</p></td> 
      </tr> 
      <tr> 
       <td class="custom-top-td acenter" width="14.38%"><p style="text-align:center">03/29/2018</p></td> 
       <td class="custom-top-td acenter" width="13.26%"><p style="text-align:center">85,365</p></td> 
       <td class="custom-top-td acenter" width="11.56%"><p style="text-align:center">-</p></td> 
       <td class="custom-top-td acenter" width="11.56%"><p style="text-align:center">-</p></td> 
       <td class="custom-top-td acenter" width="11.56%"><p style="text-align:center">-</p></td> 
       <td class="custom-top-td acenter" width="11.56%"><p style="text-align:center">-</p></td> 
       <td class="custom-top-td acenter" width="12.54%"><p style="text-align:center">-</p></td> 
       <td class="custom-top-td acenter" width="13.57%"><p style="text-align:center">-</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="14.38%"><p style="text-align:center">04/02/2018</p></td> 
       <td class="acenter" width="13.26%"><p style="text-align:center">84,666</p></td> 
       <td class="acenter" width="11.56%"><p style="text-align:center">84,790</p></td> 
       <td class="acenter" width="11.56%"><p style="text-align:center">85,148</p></td> 
       <td class="acenter" width="11.56%"><p style="text-align:center">84,721</p></td> 
       <td class="acenter" width="11.56%"><p style="text-align:center">85,141</p></td> 
       <td class="acenter" width="12.54%"><p style="text-align:center">84,760</p></td> 
       <td class="acenter" width="13.57%"><p style="text-align:center">84,820</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="14.38%"><p style="text-align:center">04/03/2018</p></td> 
       <td class="acenter" width="13.26%"><p style="text-align:center">84,623</p></td> 
       <td class="acenter" width="11.56%"><p style="text-align:center">83,484</p></td> 
       <td class="acenter" width="11.56%"><p style="text-align:center">84,315</p></td> 
       <td class="acenter" width="11.56%"><p style="text-align:center">84,721</p></td> 
       <td class="acenter" width="11.56%"><p style="text-align:center">84,553</p></td> 
       <td class="acenter" width="12.54%"><p style="text-align:center">84,760</p></td> 
       <td class="acenter" width="13.57%"><p style="text-align:center">84,820</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="14.38%"><p style="text-align:center"> 
         <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"> <mo>
            ⋮ 
          </mo> 
         </math></p></td> 
       <td class="acenter" width="13.26%"><p style="text-align:center"> 
         <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"> <mo>
            ⋮ 
          </mo> 
         </math></p></td> 
       <td class="acenter" width="11.56%"><p style="text-align:center"> 
         <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"> <mo>
            ⋮ 
          </mo> 
         </math></p></td> 
       <td class="acenter" width="11.56%"><p style="text-align:center"> 
         <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"> <mo>
            ⋮ 
          </mo> 
         </math></p></td> 
       <td class="acenter" width="11.56%"><p style="text-align:center"> 
         <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"> <mo>
            ⋮ 
          </mo> 
         </math></p></td> 
       <td class="acenter" width="11.56%"><p style="text-align:center"> 
         <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"> <mo>
            ⋮ 
          </mo> 
         </math></p></td> 
       <td class="acenter" width="12.54%"><p style="text-align:center"> 
         <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"> <mo>
            ⋮ 
          </mo> 
         </math></p></td> 
       <td class="acenter" width="13.57%"><p style="text-align:center"> 
         <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"> <mo>
            ⋮ 
          </mo> 
         </math></p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="14.38%"><p style="text-align:center">10/09/2018</p></td> 
       <td class="acenter" width="13.26%"><p style="text-align:center">86,088</p></td> 
       <td class="acenter" width="11.56%"><p style="text-align:center">84,790</p></td> 
       <td class="acenter" width="11.56%"><p style="text-align:center">85,115</p></td> 
       <td class="acenter" width="11.56%"><p style="text-align:center">84,721</p></td> 
       <td class="acenter" width="11.56%"><p style="text-align:center">84,858</p></td> 
       <td class="acenter" width="12.54%"><p style="text-align:center">84,833</p></td> 
       <td class="acenter" width="13.57%"><p style="text-align:center">84,737</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="14.38%"><p style="text-align:center">10/10/2018</p></td> 
       <td class="acenter" width="13.26%"><p style="text-align:center">83,679</p></td> 
       <td class="acenter" width="11.56%"><p style="text-align:center">84,790</p></td> 
       <td class="acenter" width="11.56%"><p style="text-align:center">85,115</p></td> 
       <td class="acenter" width="11.56%"><p style="text-align:center">84,721</p></td> 
       <td class="acenter" width="11.56%"><p style="text-align:center">84,858</p></td> 
       <td class="acenter" width="12.54%"><p style="text-align:center">84,833</p></td> 
       <td class="acenter" width="13.57%"><p style="text-align:center">84,737</p></td> 
      </tr> 
      <tr> 
       <td class="custom-bottom-td acenter" width="14.38%"><p style="text-align:center">10/11/2018</p></td> 
       <td class="custom-bottom-td acenter" width="13.26%"><p style="text-align:center">82,921</p></td> 
       <td class="custom-bottom-td acenter" width="11.56%"><p style="text-align:center">83,484</p></td> 
       <td class="custom-bottom-td acenter" width="11.56%"><p style="text-align:center">84,481</p></td> 
       <td class="custom-bottom-td acenter" width="11.56%"><p style="text-align:center">83,302</p></td> 
       <td class="custom-bottom-td acenter" width="11.56%"><p style="text-align:center">83,859</p></td> 
       <td class="custom-bottom-td acenter" width="12.54%"><p style="text-align:center">84,106</p></td> 
       <td class="custom-bottom-td acenter" width="13.57%"><p style="text-align:center">83,936</p></td> 
      </tr> 
     </table>
    </table-wrap>
    <p>The performance of the proposed model relative to existing models is summarized in <xref ref-type="table" rid="table7">
      Table 7
     </xref>, based on four different performance metrics.</p>
    <table-wrap id="table7">
     <label>
      <xref ref-type="table" rid="table7">
       Table 7
      </xref></label>
     <caption>
      <title>
       <xref ref-type="bibr" rid="scirp.142617-"></xref>Table 7. Performance comparison of the proposed model and existing models over the Ibovespa training dataset.</title>
     </caption>
     <table class="MsoTableGrid custom-table" border="0" cellspacing="0" cellpadding="0"> 
      <tr> 
       <td class="custom-bottom-td custom-top-td acenter" width="20.32%"><p style="text-align:center">Model</p></td> 
       <td class="custom-bottom-td custom-top-td acenter" width="15.59%"><p style="text-align:center">RMSE</p></td> 
       <td class="custom-bottom-td custom-top-td acenter" width="29.91%"><p style="text-align:center">RMSE relative Naive</p></td> 
       <td class="custom-bottom-td custom-top-td acenter" width="19.23%"><p style="text-align:center">R-squared</p></td> 
       <td class="custom-bottom-td custom-top-td acenter" width="14.95%"><p style="text-align:center">MAE</p></td> 
      </tr> 
      <tr> 
       <td class="custom-top-td acenter" width="20.32%"><p style="text-align:center">Chen 1996</p></td> 
       <td class="custom-top-td acenter" width="15.59%"><p style="text-align:center">1235</p></td> 
       <td class="custom-top-td acenter" width="29.91%"><p style="text-align:center">1.070</p></td> 
       <td class="custom-top-td acenter" width="19.23%"><p style="text-align:center">0.0921</p></td> 
       <td class="custom-top-td acenter" width="14.95%"><p style="text-align:center">1248</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="20.32%"><p style="text-align:center">Yu 2004</p></td> 
       <td class="acenter" width="15.59%"><p style="text-align:center">1090</p></td> 
       <td class="acenter" width="29.91%"><p style="text-align:center">0.946</p></td> 
       <td class="acenter" width="19.23%"><p style="text-align:center">0.0497</p></td> 
       <td class="acenter" width="14.95%"><p style="text-align:center">877</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="20.32%"><p style="text-align:center">Teoh 2008</p></td> 
       <td class="acenter" width="15.59%"><p style="text-align:center">1370</p></td> 
       <td class="acenter" width="29.91%"><p style="text-align:center">1.189</p></td> 
       <td class="acenter" width="19.23%"><p style="text-align:center">0.1090</p></td> 
       <td class="acenter" width="14.95%"><p style="text-align:center">1383</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="20.32%"><p style="text-align:center">Singh 2018</p></td> 
       <td class="acenter" width="15.59%"><p style="text-align:center">1032</p></td> 
       <td class="acenter" width="29.91%"><p style="text-align:center">0.896</p></td> 
       <td class="acenter" width="19.23%"><p style="text-align:center">0.0456</p></td> 
       <td class="acenter" width="14.95%"><p style="text-align:center">836</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="20.32%"><p style="text-align:center">Tavares 2022</p></td> 
       <td class="acenter" width="15.59%"><p style="text-align:center">1043</p></td> 
       <td class="acenter" width="29.91%"><p style="text-align:center">0.9108</p></td> 
       <td class="acenter" width="19.23%"><p style="text-align:center">0.0415</p></td> 
       <td class="acenter" width="14.95%"><p style="text-align:center">809</p></td> 
      </tr> 
      <tr> 
       <td class="custom-bottom-td acenter" width="20.32%"><p style="text-align:center">Proposed Model</p></td> 
       <td class="custom-bottom-td acenter" width="15.59%"><p style="text-align:center">1001</p></td> 
       <td class="custom-bottom-td acenter" width="29.91%"><p style="text-align:center">0.869</p></td> 
       <td class="custom-bottom-td acenter" width="19.23%"><p style="text-align:center">0.0388</p></td> 
       <td class="custom-bottom-td acenter" width="14.95%"><p style="text-align:center">753</p></td> 
      </tr> 
     </table>
    </table-wrap>
    <p>The next section discusses the out-of-sample test to further validate the effectiveness of the proposed model.</p>
   </sec>
   <sec id="s5_2">
    <title>5.2. Out-of-Sample Test</title>
    <p>The out-of-sample test was conducted as follows:</p>
    <p>1) Train the model using the Ibovespa dataset from 03/29/2018 to 10/11/2018.</p>
    <p>2) Predict the price for the next sample (10/15/2018). (Only business days are considered).</p>
    <p>3) On 10/12/2018, Brazil observed a holiday, and the stock market was closed. Since 10/13/2018 and 10/14/2018 were non-business days, there were no trades on these dates.</p>
    <p>4) The forecast for 10/15/2018 was recorded as forecast (1).</p>
    <p>For subsequent forecasts, the training dataset was updated by shifting it one day ahead, using data from 04/02/2018 to 10/15/2018 (real prices, not forecasts). This process was repeated for four steps, yielding forecasts forecast (1) to forecast (4). The results for all methods are shown in <xref ref-type="table" rid="table8">
      Table 8
     </xref>.</p>
    <table-wrap id="table8">
     <label>
      <xref ref-type="table" rid="table8">
       Table 8
      </xref></label>
     <caption>
      <title>
       <xref ref-type="bibr" rid="scirp.142617-"></xref>Table 8. Forecasting results for the out-of-sample test.</title>
     </caption>
     <table class="MsoTableGrid custom-table" border="0" cellspacing="0" cellpadding="0"> 
      <tr> 
       <td class="custom-bottom-td custom-top-td acenter" width="14.28%"><p style="text-align:center">Date</p></td> 
       <td class="custom-bottom-td custom-top-td acenter" width="14.29%"><p style="text-align:center">Ibovespa</p><p style="text-align:center">Real Data</p></td> 
       <td class="custom-bottom-td custom-top-td acenter" width="14.29%"><p style="text-align:center">Chen 1996</p><p style="text-align:center">Forecast</p></td> 
       <td class="custom-bottom-td custom-top-td acenter" width="14.29%"><p style="text-align:center">Yu 2004</p><p style="text-align:center">Forecast</p></td> 
       <td class="custom-bottom-td custom-top-td acenter" width="14.29%"><p style="text-align:center">Teoh 2008</p><p style="text-align:center">Forecast</p></td> 
       <td class="custom-bottom-td custom-top-td acenter" width="14.29%"><p style="text-align:center">Tavares 2022</p><p style="text-align:center">Forecast</p></td> 
       <td class="custom-bottom-td custom-top-td acenter" width="14.30%"><p style="text-align:center">Proposed</p><p style="text-align:center">Model Forecast</p></td> 
      </tr> 
      <tr> 
       <td class="custom-top-td acenter" width="14.28%"><p style="text-align:center">10/15/2018</p></td> 
       <td class="custom-top-td acenter" width="14.29%"><p style="text-align:center">83,359</p></td> 
       <td class="custom-top-td acenter" width="14.29%"><p style="text-align:center">83,484</p></td> 
       <td class="custom-top-td acenter" width="14.29%"><p style="text-align:center">83,448</p></td> 
       <td class="custom-top-td acenter" width="14.29%"><p style="text-align:center">83,144</p></td> 
       <td class="custom-top-td acenter" width="14.29%"><p style="text-align:center">83,201</p></td> 
       <td class="custom-top-td acenter" width="14.30%"><p style="text-align:center">82,789</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="14.28%"><p style="text-align:center">10/16/2018</p></td> 
       <td class="acenter" width="14.29%"><p style="text-align:center">85,717</p></td> 
       <td class="acenter" width="14.29%"><p style="text-align:center">83,484</p></td> 
       <td class="acenter" width="14.29%"><p style="text-align:center">82,815</p></td> 
       <td class="acenter" width="14.29%"><p style="text-align:center">83,121</p></td> 
       <td class="acenter" width="14.29%"><p style="text-align:center">83,156</p></td> 
       <td class="acenter" width="14.30%"><p style="text-align:center">82,978</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="14.28%"><p style="text-align:center">10/17/2018</p></td> 
       <td class="acenter" width="14.29%"><p style="text-align:center">85,763</p></td> 
       <td class="acenter" width="14.29%"><p style="text-align:center">84,790</p></td> 
       <td class="acenter" width="14.29%"><p style="text-align:center">85,315</p></td> 
       <td class="acenter" width="14.29%"><p style="text-align:center">84,559</p></td> 
       <td class="acenter" width="14.29%"><p style="text-align:center">84,602</p></td> 
       <td class="acenter" width="14.30%"><p style="text-align:center">85,389</p></td> 
      </tr> 
      <tr> 
       <td class="custom-bottom-td acenter" width="14.28%"><p style="text-align:center">10/18/2018</p></td> 
       <td class="custom-bottom-td acenter" width="14.29%"><p style="text-align:center">83,847</p></td> 
       <td class="custom-bottom-td acenter" width="14.29%"><p style="text-align:center">84,790</p></td> 
       <td class="custom-bottom-td acenter" width="14.29%"><p style="text-align:center">85,315</p></td> 
       <td class="custom-bottom-td acenter" width="14.29%"><p style="text-align:center">84,575</p></td> 
       <td class="custom-bottom-td acenter" width="14.29%"><p style="text-align:center">85,698</p></td> 
       <td class="custom-bottom-td acenter" width="14.30%"><p style="text-align:center">85,465</p></td> 
      </tr> 
     </table>
    </table-wrap>
    <p>The performance comparison among all methods in the out-of-sample test is shown in <xref ref-type="table" rid="table9">
      Table 9
     </xref>.</p>
    <table-wrap id="table9">
     <label>
      <xref ref-type="table" rid="table9">
       Table 9
      </xref></label>
     <caption>
      <title>
       <xref ref-type="bibr" rid="scirp.142617-"></xref>Table 9. Performance comparison of the proposed model and existing models over the Ibovespa testing dataset.</title>
     </caption>
     <table class="MsoTableGrid custom-table" border="0" cellspacing="0" cellpadding="0"> 
      <tr> 
       <td class="custom-bottom-td custom-top-td acenter" width="25.22%"><p style="text-align:center">Model</p></td> 
       <td class="custom-bottom-td custom-top-td acenter" width="14.77%"><p style="text-align:center">RMSE</p></td> 
       <td class="custom-bottom-td custom-top-td acenter" width="30.10%"><p style="text-align:center">RMSE relative Naive</p></td> 
       <td class="custom-bottom-td custom-top-td acenter" width="17.09%"><p style="text-align:center">R-squared</p></td> 
       <td class="custom-bottom-td custom-top-td acenter" width="12.81%"><p style="text-align:center">MAE</p></td> 
      </tr> 
      <tr> 
       <td class="custom-top-td acenter" width="25.22%"><p style="text-align:center">Chen 1996</p></td> 
       <td class="custom-top-td acenter" width="14.77%"><p style="text-align:center">1308</p></td> 
       <td class="custom-top-td acenter" width="30.10%"><p style="text-align:center">0.851</p></td> 
       <td class="custom-top-td acenter" width="17.09%"><p style="text-align:center">1.007</p></td> 
       <td class="custom-top-td acenter" width="12.81%"><p style="text-align:center">890</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="25.22%"><p style="text-align:center">Yu 2004</p></td> 
       <td class="acenter" width="14.77%"><p style="text-align:center">1642</p></td> 
       <td class="acenter" width="30.10%"><p style="text-align:center">1.070</p></td> 
       <td class="acenter" width="17.09%"><p style="text-align:center">0.801</p></td> 
       <td class="acenter" width="12.81%"><p style="text-align:center">760</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="25.22%"><p style="text-align:center">Teoh 2008</p></td> 
       <td class="acenter" width="14.77%"><p style="text-align:center">1480</p></td> 
       <td class="acenter" width="30.10%"><p style="text-align:center">0.964</p></td> 
       <td class="acenter" width="17.09%"><p style="text-align:center">1.254</p></td> 
       <td class="acenter" width="12.81%"><p style="text-align:center">1000</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="25.22%"><p style="text-align:center">Singh 2018</p></td> 
       <td class="acenter" width="14.77%"><p style="text-align:center">1627</p></td> 
       <td class="acenter" width="30.10%"><p style="text-align:center">1.060</p></td> 
       <td class="acenter" width="17.09%"><p style="text-align:center">1.166</p></td> 
       <td class="acenter" width="12.81%"><p style="text-align:center">948</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="25.22%"><p style="text-align:center">Tavares 2022</p></td> 
       <td class="acenter" width="14.77%"><p style="text-align:center">1305</p></td> 
       <td class="acenter" width="30.10%"><p style="text-align:center">0.849</p></td> 
       <td class="acenter" width="17.09%"><p style="text-align:center">0.776</p></td> 
       <td class="acenter" width="12.81%"><p style="text-align:center">754</p></td> 
      </tr> 
      <tr> 
       <td class="custom-bottom-td acenter" width="25.22%"><p style="text-align:center">Proposed Model</p></td> 
       <td class="custom-bottom-td acenter" width="14.77%"><p style="text-align:center">1293</p></td> 
       <td class="custom-bottom-td acenter" width="30.10%"><p style="text-align:center">0.842</p></td> 
       <td class="custom-bottom-td acenter" width="17.09%"><p style="text-align:center">0.722</p></td> 
       <td class="custom-bottom-td acenter" width="12.81%"><p style="text-align:center">741</p></td> 
      </tr> 
     </table>
    </table-wrap>
   </sec>
   <sec id="s5_3">
    <title>5.3. Results Discussion</title>
    <p>As observed, the forecasts generated by the proposed model are closer to the actual Ibovespa data compared to those of the other models, demonstrating superior predictive performance.</p>
    <p>The RMSE value serves as a measure of model performance, where lower RMSE values indicate higher forecasting accuracy. The proposed model exhibits the lowest RMSE among the models analyzed, signifying its superior performance.</p>
    <p>The RMSE relative to the Naïve model provides an additional benchmark. A value greater than one indicates that the model performs worse than the Naïve model, while a value below one signifies better performance. The Naïve model assumes that the forecast for the next period is equal to the actual value of the current period. The proposed model not only achieves an RMSE relative to the Naïve model below one but also outperforms all other models in this regard.</p>
    <p>Finally, the R-squared value reaches its highest level in the proposed model, indicating its superior ability to explain the variability in the original data.</p>
   </sec>
  </sec><sec id="s6">
   <title>6. Conclusions</title>
   <p>This paper presents a hybrid fuzzy time series model that incorporates the red-black tree data structure to define clusters from the universe of discourse. In terms of performance, the proposed model outperforms other models from the literature. Additionally:</p>
   <p>It is important to note, however, that this study is limited to working with qualitative variables, as it is necessary to measure numerical differences between values during the red-black tree construction phase. A concern may also arise when the data contains too many repeated values, as these are ignored during the clustering procedure.</p>
   <p>Future work will focus on enhancing the proposed model by exploring the following avenues: 1) applying the model to alternative datasets such as currency exchange rates, individual stocks, metals, and financial futures; 2) developing software to simulate the profits generated by the system regularly; and 3) experimenting with novel methods for partitioning the universe of discourse.</p>
  </sec><sec id="s7">
   <title>Impact Overview</title>
   <p>The software discussed in this paper is one of the outcomes developed during a postdoctoral program in Electrical Engineering. From a technical standpoint, the primary impact lies in the innovative organization of data using red-black trees, as well as the application of quantum mechanics principles to cluster the trees prior to the fuzzification process for the forecasting model. While the results presented in this paper demonstrate the application of the forecasting model in the field of finance, its underlying logic can be extended to other datasets from diverse domains such as engineering and biology. The software is also accessible in Matlab, as detailed in the code metadata section. From a literature perspective, three papers which used this software as the foundational methodology for their development were published in high impact journals, making a considerable impact in the Artificial Intelligence research field. One of the papers was derived from a project entitled “Fuzzy Time Series Model Based on Red-Black Trees for Stock Index Forecasting”, which resulted in a publication in 2022 in the journal “Applied Soft Computing”. One of the softwares modules, related to the fuzzification and defuzzification of the time series input data allowed the development of two different papers entitled: “Relationship Between Selic Rate and Basel III Parameters: A Statistical Approach and a Fuzzy Forecasting Model”, published in 2021 in the “Journal of Intelligent &amp; Fuzzy Systems” and “Clustering-Based Fuzzy Model for Predicting Anchor Bearing Capacity” published in 2022 in the “International Journal of Geomechanics”.</p>
  </sec><sec id="s8">
   <title>Code Metadata</title>
   <table class="MsoTableGrid custom-table" border="0" cellspacing="0" cellpadding="0"> 
    <tr> 
     <td class="custom-bottom-td custom-top-td acenter" width="5.88%"><p style="text-align:center">Nr.</p></td> 
     <td class="custom-bottom-td custom-top-td acenter" width="54.41%"><p style="text-align:center">Code metadata description</p></td> 
     <td class="custom-bottom-td custom-top-td acenter" width="39.70%"><p style="text-align:center">Please fill in this column</p></td> 
    </tr> 
    <tr> 
     <td class="custom-top-td acenter" width="5.88%"><p style="text-align:center">C1</p></td> 
     <td class="custom-top-td aleft" width="54.41%"><p style="text-align:left">Current code version</p></td> 
     <td class="custom-top-td aleft" width="39.70%"><p style="text-align:left">v1.1</p></td> 
    </tr> 
    <tr> 
     <td class="acenter" width="5.88%"><p style="text-align:center">C2</p></td> 
     <td class="aleft" width="54.41%"><p style="text-align:left">Permanent link to code/repository used for this code version</p></td> 
     <td class="aleft" width="39.70%"><p style="text-align:left">
       <xref ref-type="bibr" rid="scirp.142617-https://github.com/PJbourne/FuzzyRBTreeModel">
        https://github.com/PJbourne/FuzzyRBTreeModel
       </xref></p></td> 
    </tr> 
    <tr> 
     <td class="acenter" width="5.88%"><p style="text-align:center">C3</p></td> 
     <td class="aleft" width="54.41%"><p style="text-align:left">Permanent link to Reproducible Capsule</p></td> 
     <td class="aleft" width="39.70%"><p style="text-align:left">
       <xref ref-type="bibr" rid="scirp.142617-https://codeocean.com/capsule/0098421/tree/v1">
        https://codeocean.com/capsule/0098421/tree/v1
       </xref></p></td> 
    </tr> 
    <tr> 
     <td class="acenter" width="5.88%"><p style="text-align:center">C4</p></td> 
     <td class="aleft" width="54.41%"><p style="text-align:left">Legal Code License</p></td> 
     <td class="aleft" width="39.70%"><p style="text-align:left">MIT License</p></td> 
    </tr> 
    <tr> 
     <td class="acenter" width="5.88%"><p style="text-align:center">C5</p></td> 
     <td class="aleft" width="54.41%"><p style="text-align:left">Code versioning system used</p></td> 
     <td class="aleft" width="39.70%"><p style="text-align:left">git</p></td> 
    </tr> 
    <tr> 
     <td class="acenter" width="5.88%"><p style="text-align:center">C6</p></td> 
     <td class="aleft" width="54.41%"><p style="text-align:left">Software code languages, tools, and services used</p></td> 
     <td class="aleft" width="39.70%"><p style="text-align:left">MATLAB, Bash</p></td> 
    </tr> 
    <tr> 
     <td class="acenter" width="5.88%"><p style="text-align:center">C7</p></td> 
     <td class="aleft" width="54.41%"><p style="text-align:left">Compilation requirements, operating environments &amp; dependencies</p></td> 
     <td class="aleft" width="39.70%"><p style="text-align:left"></p></td> 
    </tr> 
    <tr> 
     <td class="acenter" width="5.88%"><p style="text-align:center">C8</p></td> 
     <td class="aleft" width="54.41%"><p style="text-align:left">If available Link to developer documentation/manual</p></td> 
     <td class="aleft" width="39.70%"><p style="text-align:left"></p></td> 
    </tr> 
    <tr> 
     <td class="custom-bottom-td acenter" width="5.88%"><p style="text-align:center">C9</p></td> 
     <td class="custom-bottom-td aleft" width="54.41%"><p style="text-align:left">Support email for questions</p></td> 
     <td class="custom-bottom-td aleft" width="39.70%"><p style="text-align:left">thiago.tavares@ifmg.edu.br</p></td> 
    </tr> 
   </table>
  </sec>
 </body><back>
  <ref-list>
   <title>References</title>
   <ref id="scirp.142617-ref1">
    <label>1</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Kendall, S. and Ord, K. (1990) Time Series. Oxford University Press.
    </mixed-citation>
   </ref>
   <ref id="scirp.142617-ref2">
    <label>2</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Huarng, K.-H. and Yu, T.H.-K. (2012) Effective Lengths of Intervals to Improve Forecasting in Fuzzy Time Series. International Journal of Innovative Computing, Information and Control, 8, 7415-7426.
    </mixed-citation>
   </ref>
   <ref id="scirp.142617-ref3">
    <label>3</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Chen, S.-M. (1996) Forecasting Enrollments Based on Fuzzy Time Series. Fuzzy Sets and Systems, 81, 311-319. &gt;https://doi.org/10.1016/0165-0114(95)00220-0
    </mixed-citation>
   </ref>
   <ref id="scirp.142617-ref4">
    <label>4</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Huarng, K. (2001) Effective Lengths of Intervals to Improve Forecasting in Fuzzy Time Series. Fuzzy Sets and Systems, 123, 387-394. &gt;https://doi.org/10.1016/s0165-0114(00)00057-9
    </mixed-citation>
   </ref>
   <ref id="scirp.142617-ref5">
    <label>5</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Liu, H. and Wei, M. (2010) An Improved Fuzzy Forecasting Method for Seasonal Time Series. Expert Systems with Applications, 37, 6310-6318. &gt;https://doi.org/10.1016/j.eswa.2010.02.090
    </mixed-citation>
   </ref>
   <ref id="scirp.142617-ref6">
    <label>6</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Chen, S. and Tanuwijaya, K. (2011) Multivariate Fuzzy Forecasting Based on Fuzzy Time Series and Automatic Clustering Techniques. Expert Systems with Applications, 38, 10594-10605. &gt;https://doi.org/10.1016/j.eswa.2011.02.098
    </mixed-citation>
   </ref>
   <ref id="scirp.142617-ref7">
    <label>7</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Wang, L., Liu, X. and Pedrycz, W. (2013) Effective Intervals Determined by Information Granules to Improve Forecasting in Fuzzy Time Series. Expert Systems with Applications, 40, 5673-5679. &gt;https://doi.org/10.1016/j.eswa.2013.04.026
    </mixed-citation>
   </ref>
   <ref id="scirp.142617-ref8">
    <label>8</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Pal, S.S. and Kar, S. (2018) Fuzzy Time Series Model for Unequal Interval Length Using Genetic Algorithm. In: Chandra, P., et al., Eds., Information Technology and Applied Mathematics, Springer, 205-216. &gt;https://doi.org/10.1007/978-981-10-7590-2_15
    </mixed-citation>
   </ref>
   <ref id="scirp.142617-ref9">
    <label>9</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Yu, H. (2005) Weighted Fuzzy Time Series Models for TAIEX Forecasting. Physica A: Statistical Mechanics and Its Applications, 349, 609-624. &gt;https://doi.org/10.1016/j.physa.2004.11.006
    </mixed-citation>
   </ref>
   <ref id="scirp.142617-ref10">
    <label>10</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Singh, P., Dhiman, G. and Kaur, A. (2018) A Quantum Approach for Time Series Data Based on Graph and Schrödinger Equations Methods. Modern Physics Letters A, 33, Article ID: 1850208. &gt;https://doi.org/10.1142/s0217732318502085
    </mixed-citation>
   </ref>
   <ref id="scirp.142617-ref11">
    <label>11</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Teoh, H.J., Cheng, C., Chu, H. and Chen, J. (2008) Fuzzy Time Series Model Based on Probabilistic Approach and Rough Set Rule Induction for Empirical Research in Stock Markets. Data &amp; Knowledge Engineering, 67, 103-117. &gt;https://doi.org/10.1016/j.datak.2008.06.002
    </mixed-citation>
   </ref>
   <ref id="scirp.142617-ref12">
    <label>12</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Cheng, C. and Yang, J. (2018) Fuzzy Time-Series Model Based on Rough Set Rule Induction for Forecasting Stock Price. Neurocomputing, 302, 33-45. &gt;https://doi.org/10.1016/j.neucom.2018.04.014
    </mixed-citation>
   </ref>
   <ref id="scirp.142617-ref13">
    <label>13</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Guibas, L.J. and Sedgewick, R. (1978) A Dichromatic Framework for Balanced Trees. 19th Annual Symposium on Foundations of Computer Science (SFCS 1978), Ann Arbor, 16-18 October 1978, 8-21. &gt;https://doi.org/10.1109/sfcs.1978.3
    </mixed-citation>
   </ref>
   <ref id="scirp.142617-ref14">
    <label>14</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Chen, S. and Chang, Y. (2010) Multi-Variable Fuzzy Forecasting Based on Fuzzy Clustering and Fuzzy Rule Interpolation Techniques. Information Sciences, 180, 4772-4783. &gt;https://doi.org/10.1016/j.ins.2010.08.026
    </mixed-citation>
   </ref>
   <ref id="scirp.142617-ref15">
    <label>15</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Carvalho, J.G. and Costa, C.T. (2017) Identification Method for Fuzzy Forecasting Models of Time Series. Applied Soft Computing, 50, 166-182. &gt;https://doi.org/10.1016/j.asoc.2016.11.003
    </mixed-citation>
   </ref>
   <ref id="scirp.142617-ref16">
    <label>16</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Mohamad Hanapi, A.L., Othman, M., Sokkalingam, R., Ramli, N., Husin, A. and Vasant, P. (2020) A Novel Fuzzy Linear Regression Sliding Window GARCH Model for Time-Series Forecasting. Applied Sciences, 10, Article No. 1949. &gt;https://doi.org/10.3390/app10061949
    </mixed-citation>
   </ref>
   <ref id="scirp.142617-ref17">
    <label>17</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Alameer, Z., Elaziz, M.A., Ewees, A.A., Ye, H. and Jianhua, Z. (2019) Forecasting Copper Prices Using Hybrid Adaptive Neuro-Fuzzy Inference System and Genetic Algorithms. Natural Resources Research, 28, 1385-1401. &gt;https://doi.org/10.1007/s11053-019-09473-w
    </mixed-citation>
   </ref>
   <ref id="scirp.142617-ref18">
    <label>18</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Tavares, T.H.B.d.C., Ferreira, B.P. and Mendes, E.M.A.M. (2022) Relationship between Selic Rate and Basel III Parameters—A Statistics Approach and a Fuzzy Forecasting Model. Journal of Intelligent &amp; Fuzzy Systems, 42, 5681-5694. &gt;https://doi.org/10.3233/jifs-212128
    </mixed-citation>
   </ref>
   <ref id="scirp.142617-ref19">
    <label>19</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Tavares, T.H.B.C., Porto, T.B., Ferreira, B.P. and Marçal Mendes, E.M. (2023) Clustering-Based Fuzzy Model for Predicting Anchor Bearing Capacity. International Journal of Geomechanics, 23, 1-12. &gt;https://doi.org/10.1061/ijgnai.gmeng-6961
    </mixed-citation>
   </ref>
   <ref id="scirp.142617-ref20">
    <label>20</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Kuo, R.J., Chen, C.H. and Hwang, Y.C. (2001) An Intelligent Stock Trading Decision Support System through Integration of Genetic Algorithm Based Fuzzy Neural Network and Artificial Neural Network. Fuzzy Sets and Systems, 118, 21-45. &gt;https://doi.org/10.1016/s0165-0114(98)00399-6
    </mixed-citation>
   </ref>
   <ref id="scirp.142617-ref21">
    <label>21</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     McMillan, D.G. (2007) Non-Linear Forecasting of Stock Returns: Does Volume Help? International Journal of Forecasting, 23, 115-126. &gt;https://doi.org/10.1016/j.ijforecast.2006.06.002
    </mixed-citation>
   </ref>
   <ref id="scirp.142617-ref22">
    <label>22</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Miller, G.A. (1956) The Magical Number Seven, plus or minus Two: Some Limits on Our Capacity for Processing Information. Psychological Review, 63, 81-97. &gt;https://doi.org/10.1037/h0043158
    </mixed-citation>
   </ref>
   <ref id="scirp.142617-ref23">
    <label>23</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Song, Q. and Chissom, B.S. (1993) Fuzzy Time Series and Its Models. Fuzzy Sets and Systems, 54, 269-277. &gt;https://doi.org/10.1016/0165-0114(93)90372-o
    </mixed-citation>
   </ref>
   <ref id="scirp.142617-ref24">
    <label>24</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Takiyar, S., Upadhyay, K.G. and Singh, V. (2015) Fuzzy ARTMAP and GARCH‐Based Hybrid Model Aided with Wavelet Transform for Short‐Term Electricity Load Forecasting. Energy Science &amp; Engineering, 4, 14-22. &gt;https://doi.org/10.1002/ese3.105
    </mixed-citation>
   </ref>
   <ref id="scirp.142617-ref25">
    <label>25</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Wang, L.-X. (1997) A Course in Fuzzy Systems and Control. Prentice-Hall International, Inc.
    </mixed-citation>
   </ref>
   <ref id="scirp.142617-ref26">
    <label>26</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Zadeh, L.A. (1965) Fuzzy Sets. Information and Control, 8, 338-353. &gt;https://doi.org/10.1016/s0019-9958(65)90241-x
    </mixed-citation>
   </ref>
   <ref id="scirp.142617-ref27">
    <label>27</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Song, Q. and Chissom, B.S. (1993) Forecasting Enrollments with Fuzzy Time Series—Part I. Fuzzy Sets and Systems, 54, 1-9. &gt;https://doi.org/10.1016/0165-0114(93)90355-l
    </mixed-citation>
   </ref>
   <ref id="scirp.142617-ref28">
    <label>28</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Zadeh, L.A. (1975) The Concept of a Linguistic Variable and Its Application to Approximate Reasoning—I. Information Sciences, 8, 199-249. &gt;https://doi.org/10.1016/0020-0255(75)90036-5
    </mixed-citation>
   </ref>
   <ref id="scirp.142617-ref29">
    <label>29</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Besa, J. and Eterovic, Y. (2013) A Concurrent Red-Black Tree. Journal of Parallel and Distributed Computing, 73, 434-449. &gt;https://doi.org/10.1016/j.jpdc.2012.12.010 
    </mixed-citation>
   </ref>
   <ref id="scirp.142617-ref30">
    <label>30</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Tavares, T.H.B.d.C., Ferreira, B.P. and Mendes, E.M.A.M. (2022) Fuzzy Time Series Model Based on Red-Black Trees for Stock Index Forecasting. Applied Soft Computing, 127, Article ID: 109323. &gt;https://doi.org/10.1016/j.asoc.2022.109323
    </mixed-citation>
   </ref>
  </ref-list>
 </back>
</article>