\subsubsection{Yield Curves}

The top level XML elements for each \lstinline!YieldCurve! node are shown in Listing \ref{lst:top_level_yc}.

\begin{listing}[H]
%\hrule\medskip
\begin{minted}[fontsize=\footnotesize]{xml}
<YieldCurve>
  <CurveId> </CurveId>
  <CurveDescription> </CurveDescription>
  <Currency> </Currency>
  <DiscountCurve> </DiscountCurve>
  <Segments> </Segments>
  <InterpolationVariable> </InterpolationVariable>
  <InterpolationMethod> </InterpolationMethod>
  <ZeroDayCounter> </ZeroDayCounter>
  <Tolerance> </Tolerance>
  <Extrapolation> </Extrapolation>
  <BootstrapConfig>
    ...
  </BootstrapConfig>
</YieldCurve>
\end{minted}
\caption{Top level yield curve node}
\label{lst:top_level_yc}
\end{listing}

The meaning of each of the top level elements in Listing \ref{lst:top_level_yc} is given below. If an element is labelled
as 'Optional', then it may be excluded or included and left blank.
\begin{itemize}
\item CurveId: Unique identifier for the yield curve.
\item CurveDescription: A description of the yield curve. This field may be left blank.
\item Currency: The yield curve currency.
\item DiscountCurve: If the yield curve is being bootstrapped from market instruments, this gives the CurveId of the
yield curve used to discount cash flows during the bootstrap procedure. If this field is left blank or set equal to the
current CurveId, then this yield curve itself is used to discount cash flows during the bootstrap procedure.
\item Segments: This element contains child elements and is described in the following subsection.
\item InterpolationVariable [Optional]: The variable on which the interpolation is performed. The allowable values are
given in Table \ref{tab:allow_interp_variables}. If the element is omitted or left blank, then it defaults to
\emph{Discount}.
\item InterpolationMethod [Optional]: The interpolation method to use. The allowable values are given in Table
\ref{tab:allow_interp_methods}. If the element is omitted or left blank, then it defaults to \emph{LogLinear}.
\item ZeroDayCounter [Optional]: The day count basis used internally by the yield curve to calculate the time between
dates. In particular, if the curve is queried for a zero rate without specifying the day count basis, the zero rate that
is returned has this basis. If the element is omitted or left blank, then it defaults to \emph{A365}.

\item \lstinline!Tolerance! [Optional]: The tolerance used by the root finding procedure in the bootstrapping algorithm. If the
element is omitted or left blank, then it defaults to \num[scientific-notation=true]{1.0e-12}. It is preferable to use the
\lstinline!Accuracy! node in the \lstinline!BootstrapConfig! node below for specifying this value. However, if this node is
explicitly supplied, it takes precedence for backwards compatibility purposes.

\item Extrapolation [Optional]: Set to \emph{True} or \emph{False} to enable or disable extrapolation respectively. If
the element is omitted or left blank, then it defaults to \emph{True}.

\item \lstinline!BootstrapConfig! [Optional]: this node holds configuration details for the iterative bootstrap
that are described in section \ref{sec:bootstrap_config}. If omitted, this node's default values described
in section \ref{sec:bootstrap_config} are used.

\end{itemize}

\begin{table}[h]
\centering
  \begin{tabular}{|l|l|}
    \hline
    {\bfseries Variable} & {\bfseries Description} \\
    \hline
    Zero & The continuously compounded zero rate \\ \hline
    Discount & The discount factor \\ \hline
    Forward & The instantaneous forward rate \\ \hline
  \end{tabular}
  \caption{Allowable interpolation variables.}
  \label{tab:allow_interp_variables}
\end{table}

\begin{table}[h]
\centering
  \begin{tabular} {|l|p{10cm}|}
    \hline
    {\bfseries Method} & {\bfseries Description} \\
    \hline
    Linear & Linear interpolation \\ \hline
    LogLinear & Linear interpolation on the natural log of the interpolation variable \\ \hline
    NaturalCubic & Monotonic Kruger cubic interpolation with second derivative at left and right \\ \hline
    FinancialCubic & Monotonic Kruger cubic interpolation with second derivative at left and
                     first derivative at right \\ \hline
    ConvexMonotone & Convex Monotone Interpolation (Hagan, West) \\ \hline
    Quadratic & Quadratic interpolation \\ \hline
    LogQuadratic & Quadratic interpolation on the natural log of the interpolation variable \\ \hline
    Hermite & Hermite cubic spline interpolation \\ \hline
    CubicSpline & Non-monotonic cubic spline interpolation with second derivative at left and right \\ \hline
    ExponentialSplines & Exponential Spline curve fitting, for Fitted Bond Curves only \\ \hline
    NelsonSiegel & Nelson-Siegel curve fitting, for Fitted Bond Curves only \\ \hline
    Svensson & Svensson curve fitting, for Fitted Bond Curves only \\ \hline
  \end{tabular}
  \caption{Allowable interpolation methods.}
  \label{tab:allow_interp_methods}
\end{table}
%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
\subsubsection*{Segments Node} \label{ss:segments_node}
%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
The \lstinline!Segments! node gives the zero rates, discount factors and instruments that comprise the yield curve. This
node consists of a number of child nodes where the node name depends on the segment being described. Each node has a
\lstinline!Type! that determines its structure. The following sections describe the type of child nodes that are
available. Note that for all segment types below, with the exception of \lstinline!DiscountRatio! and \lstinline!AverageOIS!, the
\lstinline!Quote! elements within the \lstinline!Quotes! node may have an \lstinline!optional! attribute indicating whether or
not the quote is optional. Example:
%\hrule\medskip
\begin{minted}[fontsize=\footnotesize]{xml}
<Quotes>
  <Quote optional="true"></Quote>
</Quotes>
\end{minted}
%\hrule

\subsubsection*{Direct Segment}
When the node name is \lstinline!Direct!, the \lstinline!Type! node has the value \emph{Zero} or \emph{Discount} and the
node has the structure shown in Listing \ref{lst:direct_segment}. We refer to this segment here as a direct segment
because the discount factors, or equivalently the zero rates, are given explicitly and do not need to be
bootstrapped. The \lstinline!Quotes! node contains a list of \lstinline!Quote! elements. Each \lstinline!Quote! element
contains an ID pointing to a line in the {\tt market.txt} file, i.e.\ in this case, pointing to a particular zero rate
or discount factor. The \lstinline!Conventions! node contains the ID of a node in the {\tt conventions.xml} file
described in section \ref{sec:conventions}. The \lstinline!Conventions! node associates conventions with the quotes.

\begin{listing}[H]
%\hrule\medskip
\begin{minted}[fontsize=\footnotesize]{xml}
<Direct>
  <Type> </Type>
  <Quotes>
    <Quote> </Quote>
    <Quote> </Quote>
     <!--...-->
  </Quotes>
  <Conventions> </Conventions>
</Direct>
\end{minted}
\caption{Direct yield curve segment}
\label{lst:direct_segment}
\end{listing}

\subsubsection*{Simple Segment}
When the node name is \lstinline!Simple!, the \lstinline!Type! node has the value \emph{Deposit}, \emph{FRA},
\emph{Future}, \emph{OIS}, \emph{Swap} or \emph{BMA Basis Swap} and the node has the structure shown in Listing
\ref{lst:simple_segment}. This segment holds quotes for a set of deposit, FRA, Future, OIS or swap instruments
corresponding to the value in the \lstinline!Type! node. These quotes will be used by the bootstrap algorithm to imply
a discount factor, or equivalently a zero rate, curve. The only difference between this segment and the direct segment
is that there is a \lstinline!ProjectionCurve! node. This node allows us to specify the CurveId of another curve to
project floating rates on the instruments underlying the quotes listed in the \lstinline!Quote! nodes during the
bootstrap procedure. This is an optional node. If it is left blank or omitted, then the projection curve is assumed to
equal the curve being bootstrapped i.e.\ the current CurveId.

\begin{listing}[H]
%\hrule\medskip
\begin{minted}[fontsize=\footnotesize]{xml}
<Simple>
  <Type> </Type>
  <Quotes>
    <Quote> </Quote>
    <Quote> </Quote>
    <!--...-->
  </Quotes>
  <Conventions> </Conventions>
  <ProjectionCurve> </ProjectionCurve>
</Simple>
\end{minted}
\caption{Simple yield curve segment}
\label{lst:simple_segment}
\end{listing}

\subsubsection*{Average OIS Segment}
When the node name is \lstinline!AverageOIS!, the \lstinline!Type! node has the value \emph{Average OIS} and the node
has the structure shown in Listing \ref{lst:average_ois_segment}. This segment is used to hold quotes for Average OIS
swap instruments. The \lstinline!Quotes! node has the structure shown in Listing \ref{lst:average_ois_quotes}. Each
quote for an Average OIS instrument (a typical example in a USD Overnight Index Swap) consists of two quotes, a vanilla
IRS quote and an OIS-LIBOR basis swap spread quote.  The IDs of these two quotes are stored in the
\lstinline!CompositeQuote! node. The \lstinline!RateQuote! node holds the ID of the vanilla IRS quote and the
\lstinline!SpreadQuote! node holds the ID of the OIS-LIBOR basis swap spread quote.

\begin{listing}[H]
%\hrule\medskip
\begin{minted}[fontsize=\footnotesize]{xml}
<AverageOIS>
  <Type> </Type>
  <Quotes>
    <CompositeQuote> </CompositeQuote>
    <CompositeQuote> </CompositeQuote>
    <!--...-->
  </Quotes>
  <Conventions> </Conventions>
  <ProjectionCurve> </ProjectionCurve>
</AverageOIS>
\end{minted}
\caption{Average OIS yield curve segment}
\label{lst:average_ois_segment}
\end{listing}

\begin{listing}[H]
%\hrule\medskip
\begin{minted}[fontsize=\footnotesize]{xml}
<Quotes>
  <CompositeQuote>
    <SpreadQuote> </SpreadQuote>
    <RateQuote> </RateQuote>
  </CompositeQuote>
  <!--...-->
</Quotes>
\end{minted}
\caption{Average OIS segment's quotes section}
\label{lst:average_ois_quotes}
\end{listing}

\subsubsection*{Tenor Basis Segment}
When the node name is \lstinline!TenorBasis!, the \lstinline!Type! node has the value \emph{Tenor Basis Swap} or
\emph{Tenor Basis Two Swaps} and the node has the structure shown in Listing \ref{lst:tenor_basis_segment}. This segment
is used to hold quotes for tenor basis swap instruments. The quotes may be for a conventional tenor basis swap where
Ibor of one tenor is swapped for Ibor of another tenor plus a spread. In this case, the \lstinline!Type! node has the
value \emph{Tenor Basis Swap}. The quotes may also be for the difference in fixed rates on two fair swaps where one swap
is against Ibor of one tenor and the other swap is against Ibor of another tenor. In this case, the \lstinline!Type!
node has the value \emph{Tenor Basis Two Swaps}. Again, the structure is similar to the simple segment in Listing
\ref{lst:simple_segment} except that there are two projection curve nodes. There is a \lstinline!ProjectionCurveShort!
node for the index with the shorter tenor. This node holds the CurveId of a curve for projecting the floating rates on
the short tenor index. Similarly, there is a \lstinline!ProjectionCurveLong! node for the index with the longer
tenor. This node holds the CurveId of a curve for projecting the floating rates on the long tenor index. These are
optional nodes. If they are left blank or omitted, then the projection curve is assumed to equal the curve being
bootstrapped i.e.\ the current CurveId. However, at least one of the nodes needs to be populated to allow the bootstrap
to proceed.

\begin{listing}[H]
%\hrule\medskip
\begin{minted}[fontsize=\footnotesize]{xml}
<TenorBasis>
  <Type> </Type>
  <Quotes>
    <Quote> </Quote>
    <Quote> </Quote>
    <!--...-->
  </Quotes>
  <Conventions> </Conventions>
  <ProjectionCurveLong> </ProjectionCurveLong>
  <ProjectionCurveShort> </ProjectionCurveShort>
</TenorBasis>
\end{minted}
\caption{Tenor basis yield curve segment}
\label{lst:tenor_basis_segment}
\end{listing}

\subsubsection*{Cross Currency Segment}
When the node name is \lstinline!CrossCurrency!, the \lstinline!Type! node has the value \emph{FX Forward},
\emph{Cross Currency Basis Swap} or \emph{Cross Currency Fix Float Swap}. When the \lstinline!Type! node has the value
\emph{FX Forward}, the node has the structure shown in Listing \ref{lst:fx_forward_segment}. This segment is used to
hold quotes for FX forward instruments. The \lstinline!DiscountCurve! node holds the CurveId of a curve used to
discount cash flows in the other currency i.e.\ the currency in the currency pair that is not equal to the currency in
Listing \ref{lst:top_level_yc}. The \lstinline!SpotRate! node holds the ID of a spot FX quote for the currency pair that
is looked up in the {\tt market.txt} file.

\begin{listing}[H]
%\hrule\medskip
\begin{minted}[fontsize=\footnotesize]{xml}
<CrossCurrency>
  <Type> </Type>
  <Quotes>
    <Quote> </Quote>
    <Quote> </Quote>
          ...
  </Quotes>
  <Conventions> </Conventions>
  <DiscountCurve> </DiscountCurve>
  <SpotRate> </SpotRate>
</CrossCurrency>
\end{minted}
\caption{FX forward yield curve segment}
\label{lst:fx_forward_segment}
\end{listing}

When the \lstinline!Type! node has the value \emph{Cross Currency Basis Swap} then the node has the structure shown in
Listing \ref{lst:xccy_basis_segment}. This segment is used to hold quotes for cross currency basis swap instruments. The
\lstinline!DiscountCurve! node holds the CurveId of a curve used to discount cash flows in the other currency i.e.\ the
currency in the currency pair that is not equal to the currency in Listing \ref{lst:top_level_yc}. The
\lstinline!SpotRate! node holds the ID of a spot FX quote for the currency pair that is looked up in the {\tt
  market.txt} file. The \lstinline!ProjectionCurveDomestic! node holds the CurveId of a curve for projecting the
floating rates on the index in this currency i.e.\ the currency in the currency pair that is equal to the currency in
Listing \ref{lst:top_level_yc}. It is an optional node and if it is left blank or omitted, then the projection curve is
assumed to equal the curve being bootstrapped i.e.\ the current CurveId. Similarly, the
\lstinline!ProjectionCurveForeign! node holds the CurveId of a curve for projecting the floating rates on the index in
the other currency. If it is left blank or omitted, then it is assumed to equal the CurveId provided in the
\lstinline!DiscountCurve! node in this segment.

\begin{listing}[H]
%\hrule\medskip
\begin{minted}[fontsize=\footnotesize]{xml}
<CrossCurrency>
  <Type> </Type>
  <Quotes>
    <Quote> </Quote>
    <Quote> </Quote>
          ...
  </Quotes>
  <Conventions> </Conventions>
  <DiscountCurve> </DiscountCurve>
  <SpotRate> </SpotRate>
  <ProjectionCurveDomestic> </ProjectionCurveDomestic>
  <ProjectionCurveForeign> </ProjectionCurveForeign>
</CrossCurrency>
\end{minted}
\caption{Cross currency basis yield curve segment}
\label{lst:xccy_basis_segment}
\end{listing}

\subsubsection*{Zero Spread Segment}

When the node name is \lstinline!ZeroSpread!, the \lstinline!Type!
node has the only allowable value \emph{Zero Spread},  and the node has the structure shown in
Listing \ref{lst:zero_spread_segment}. This segment is used to build yield
curves which are expressed as a spread over some reference yield curve.

\begin{listing}[H]
%\hrule\medskip
\begin{minted}[fontsize=\footnotesize]{xml}
    <ZeroSpread>
          <Type>Zero Spread</Type>
          <Quotes>
            <Quote>ZERO/YIELD_SPREAD/EUR/BANK_EUR_LEND/A365/2Y</Quote>
            <Quote>ZERO/YIELD_SPREAD/EUR/BANK_EUR_LEND/A365/5Y</Quote>
            <Quote>ZERO/YIELD_SPREAD/EUR/BANK_EUR_LEND/A365/10Y</Quote>
            <Quote>ZERO/YIELD_SPREAD/EUR/BANK_EUR_LEND/A365/20Y</Quote>
          </Quotes>
          <Conventions>EUR-ZERO-CONVENTIONS-TENOR-BASED</Conventions>
          <ReferenceCurve>EUR1D</ReferenceCurve>
    </ZeroSpread>
\end{minted}
\caption{Zero spread yield curve segment}
\label{lst:zero_spread_segment}
\end{listing}

\subsubsection*{Fitted Bond Segment}
\label{sec:fitted_bond_segment}

When the node name is \lstinline!FittedBond!, the \lstinline!Type! node has the only allowable value \emph{FittedBond},
and the node has the structure shown in Listing \ref{lst:fitted_bond_segment}. This segment is used to build yield
curves which are fitted to liquid bond prices. The segment has the following elements:

\begin{itemize}
\item Quotes: a list of bond price quotes, for each security in the list, reference data must be available
\item IborIndexCurves: for each Ibor index that is required by one of the bonds to which the curve is fitted, a mapping
  to an estimation curve for that index must be provided
\item ExtrapolateFlat: if true, the parametric curve is extrapolated flat in the instantaneous forward rate before the
  first and after the last maturity of the bonds in the calibration basket. This avoids unrealistic rates at the short
  end or for long maturities in the resulting curve.
\end{itemize}

The \lstinline!BootstrapConfig! has the following interpretation for a fitted bond curve:

\begin{itemize}
\item Accuracy [Optional, defaults to 1E-12]: the desired accuracy expressed as a weighted rmse in the implied quote,
  where 0.01 = 1 bp. Once this accuracy is reached in a calibration trial, the fit is accepted, no further calibration
  trials re run. In general, this parameter should be set to a higher than the default value for fitted bond curves.
\item GlobalAccuracy [Optional]: the acceptable accuracy. If the Accuracy is not reached in any calibration trial, but
  the GloablAccuracy is met, the best fit among the calibration trials is selected as a result of the calibration. If
  not given, the best calibration trial is compared to the Accuracy parameter instead.
\item DontThrow [Optional, defaults to false]: If true, the best calibration is always accepted as a result, i.e. no
  error is thrown even if the GlobalAccuracy is breached.
\item MaxAttempts [Optional, defaults to 5]: The maximum number of calibration trials. Each calibration trial is run with a random calibratio
  seed. Random calibration seeds are currently only supported for the NelsonSiegel interpolation method.
\end{itemize}

\begin{listing}[H]
%\hrule\medskip
\begin{minted}[fontsize=\footnotesize]{xml}
    <YieldCurve>
      ...
      <Segments>
        <FittedBond>
          <Type>FittedBond</Type>
          <Quotes>
            <Quote>BOND/PRICE/SECURITY_1</Quote>
            <Quote>BOND/PRICE/SECURITY_2</Quote>
            <Quote>BOND/PRICE/SECURITY_3</Quote>
            <Quote>BOND/PRICE/SECURITY_4</Quote>
            <Quote>BOND/PRICE/SECURITY_5</Quote>
          </Quotes>
          <!-- mapping of Ibor curves used in the bonds from which the curve is built -->
          <IborIndexCurves>
            <IborIndexCurve iborIndex="EUR-EURIBOR-6M">EUR-EURIBOR-6M</IborIndexCurve>
          </IborIndexCurves>
          <!-- flat extrapolation before first and after last bond maturity -->
          <ExtrapolateFlat>true</ExtrapolateFlat>
        </FittedBond>
      </Segments>
      <!-- NelsonSiegel, Svensson, ExponentialSplines -->
      <InterpolationMethod>NelsonSiegel</InterpolationMethod>
      <YieldCurveDayCounter>A365</YieldCurveDayCounter>
      <Extrapolation>true</Extrapolation>
      <BootstrapConfig>
        <!-- desired accuracy (in implied quote) -->
        <Accuracy>0.1</Accuracy>
        <!-- tolerable accuracy -->
        <GlobalAccuracy>0.5</GlobalAccuracy>
        <!-- do not throw even if tolerable accuracy is breached -->
        <DontThrow>false</DontThrow>
        <!-- max calibration trials to reach desired accuracy -->
        <MaxAttempts>20</MaxAttempts>
      </BootstrapConfig>
    </YieldCurve>
\end{minted}
\caption{Fitted bond yield curve segment}
\label{lst:fitted_bond_segment}
\end{listing}

\subsubsection*{Yield plus Default Segment}
\label{sec:yield_plus_default}

When the node name is \lstinline!YieldPlusDefault!, the \lstinline!Type! node has the only allowable value \emph{Yield
 Plus Default}, and the node has the structure shown in Listing \ref{lst:yield_plus_default_segment}. This segment is
used to build all-in discounting yield curves from a benchmark curve and (a weighted sum of) default curves. The
construction is in some sense inverse to the benchmark default curve construction, see \ref{ss:benchmark_default_curve}.

\begin{itemize}
\item ReferenceCurve: the benchmark yield curve serving as the basis of the resulting yield curve
\item DefaultCurves: a list of default curves whose weighted sum is added to the benchmark yield curve
\item Weights: a list of weights for the default curves, the number of weights must match the number of default curves
\end{itemize}

Notice that it is explicitly allowed to use default curves in different currencies than the benchmark yield curve. In
the construction, the hazard rate is reinterpreted as an instantaneous forward rate, and the sum of the curves is being
built in the instantaneous forward rate.

The definition takes into account the recovery rates associated to each default curve. The resulting discount factor is
computed as

\begin{equation}
P(0,t) = \prod_i  S_i(t)^{(1-R)w_i}
\end{equation}

where $S_i$ and $R_i$ are the survival probabilities and recovery rates of the source default curves, and $w_i$ are the
weights.

\begin{listing}[H]
%\hrule\medskip
\begin{minted}[fontsize=\footnotesize]{xml}
  <YieldCurve>
    <CurveId>BenchmarkPlusDefault</CurveId>
    <CurveDescription>USD Libor 3M + 0.5 x CDX.NA.HY + 0.5 x EUR.10BP</CurveDescription>
    <Currency>USD</Currency>
    <DiscountCurve/>
    <Segments>
      <YieldPlusDefault>
        <Type>Yield Plus Default</Type>
        <ReferenceCurve>USD3M</ReferenceCurve>
        <DefaultCurves>
          <DefaultCurve>Default/USD/CDX.NA.HY</DefaultCurve>
          <DefaultCurve>Default/EUR/EUR.10BP</DefaultCurve>
        </DefaultCurves>
        <Weights>
          <Weight>0.5</Weight>
          <Weight>0.5</Weight>
        </Weights>
      </YieldPlusDefault>
    </Segments>
  </YieldCurve>
</YieldCurves>
\end{minted}
\caption{Yield plus default curve segment}
\label{lst:yield_plus_default_segment}
\end{listing}

\subsubsection*{Weighted Average Segment}
\label{sec:weigthed_average}

When the node name is \lstinline!WeightedAverage!, the \lstinline!Type! node has the only allowable value
\emph{Weighted Average}, and the node has the structure shown in Listing \ref{lst:weighted_average_segment}. This segment
is used to build a curve with instantaneous forward rates that are the weighted sum of instantaneous forward rates of
reference curves. This way a projection curve for non-standard Ibor curves can be build, e.g. to project a Euribor2M
index using the curves for 1M and 3M.

\begin{itemize}
\item ReferenceCurve1: the first source curve
\item ReferenceCurve2: the second source curve
\item Weight1: the weight of the first curve
\item Weights: the weight of the second curve
\end{itemize}

If $P_1(0,t)$ and $P_2(0,t)$ denote the discount factors of the two reference curves, the discount factor $P(0,t)$ of
the resulting curve is defined as

\begin{equation}
P(0,t) = P_1(0,t)^{w_1}P_2(0,t)^{w_2}
\end{equation}

\begin{listing}[H]
%\hrule\medskip
\begin{minted}[fontsize=\footnotesize]{xml}
<YieldCurve>
  <CurveId>EUR2M</CurveId>
  <CurveDescription>Euribor2M forwarding curve, interpolated from 1M and 3M</CurveDescription>
  <Currency>EUR</Currency>
  <DiscountCurve>EUR1D</DiscountCurve>
  <Segments>
    <WeightedAverage>
      <Type>Weighted Average</Type>
      <ReferenceCurve1>EUR1M</ReferenceCurve1>
      <ReferenceCurve2>EUR3M</ReferenceCurve2>
      <Weight1>0.5</Weight1>
      <Weight2>0.5</Weight2>
    </WeightedAverage>
  </Segments>
</YieldCurve>
\end{minted}
\caption{Weighted Average yield curve segment}
\label{lst:weighted_average_segment}
\end{listing}

\subsubsection*{Ibor Fallback Segment}
\label{sec:ibor_fallback_curve_segment}

When the node name is \lstinline!IborFallback!, the \lstinline!Type! node has the only allowable value \emph{Ibor
  Fallback}, and the node has the structure shown in Listing \ref{lst:ibor_fallback_segment}. This segment is used to
build a projection curve for an Ibor index based on a risk free rate and a spread.

\begin{listing}[H]
%\hrule\medskip
\begin{minted}[fontsize=\footnotesize]{xml}
<YieldCurve>
  <CurveId>USD-LIBOR-3M</CurveId>
  <CurveDescription>USD-Libor-3M built from USD-SOFR plus spread</CurveDescription>
  <Currency>USD</Currency>
  <DiscountCurve/>
  <Segments>
    <IborFallback>
      <Type>Ibor Fallback</Type>
      <IborIndex>USD-LIBOR-3M</IborIndex>
      <RfrCurve>Yield/USD/USD-SOFR</RfrCurve>
      <!-- optional, if not given the rfr index and sprad are read from the ibor
           fallback configuration -->
      <RfrIndex>USD-SOFR</RfrIndex>
      <Spread>0.0026161</Spread>
    </IborFallback>
  </Segments>
</YieldCurve>
\end{minted}
\caption{Ibor fallback segment}
\label{lst:ibor_fallback_segment}
\end{listing}


\chapter{Classification}

\section{Introduction}

Image classification consists in extracting added-value information from images.
Such processing methods classify pixels within images into geographical connected
zones with similar properties, and identified by a common class label. The
classification can be either unsupervised or supervised.

Unsupervised classification does not require any additional information about the
properties of the input image to classify it. On the contrary, supervised methods
need a preliminary learning to be computed over training datasets having similar
properties than the image to classify, in order to build a classification model.

%In statistical classification, each object is represented by $d$ features (a
%measurement vector), and the goal of classification becomes finding compact and
%disjoint regions (decision regions\cite{Duda2000}) for classes in a
%$d$-dimensional feature space. Such decision regions are defined by decision
%rules that are known or can be trained.  The simplest configuration of a
%classification consists of a decision rule and multiple membership functions;
%each membership function represents a class. Figure~\ref{fig:simple}
%illustrates this general framework.

%\begin{figure}[h]
%  \centering
%  \includegraphics[width=0.7\textwidth]{DudaClassifier.eps}
%  \itkcaption[Simple conceptual classifier]{Simple conceptual classifier.}
%  \label{fig:simple}
%\end{figure}

%This framework closely follows that of Duda and
%Hart\cite{Duda2000}. The classification process can be described
%as follows:

%\begin{enumerate}
%\item{A measurement vector is input to each membership function.}
%\item{Membership functions feed the membership scores to the
%    decision rule.}
%\item{A decision rule compares the membership scores and returns a
%    class label.}
%\end{enumerate}

%\begin{figure}
%  \centering
%  \includegraphics[width=0.7\textwidth]{StatisticalClassificationFramework.eps}
%  \itkcaption[Statistical classification framework]{Statistical classification
%framework.}
%  \protect\label{fig:StatisticalClassificationFramework}
%\end{figure}

%This simple configuration can be used to formulated various classification
%tasks by using different membership functions and incorporating task specific
%requirements and prior knowledge into the decision rule. For example, instead
%of using probability density functions as membership functions, through
%distance functions and a minimum value decision rule (which assigns a class
%from the distance function that returns the smallest value) users can achieve a
%least squared error classifier. As another example, users can add a rejection
%scheme to the decision rule so that even in a situation where the membership
%scores suggest a ``winner'', a measurement vector can be flagged as ill
%defined. Such a rejection scheme can avoid risks of assigning a class label
%without a proper win margin.

%Note that to use these concepts into your own programs, you might have to link
%to other OTB libraries (edit the \code{TARGET\_LINK\_LIBRARIES} to add them),
%for example OTBLearning, OTBMarkov.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Machine Learning Framework}

\subsection{Machine learning models}
\label{sec:MLGenericFramework}

The OTB classification is implemented as a generic Machine Learning
framework, supporting several possible machine learning libraries as backends.
The base class \doxygen{otb}{MachineLearningModel} defines this framework.
As of now libSVM (the machine learning library historically integrated in OTB),
machine learning methods of OpenCV library (\cite{opencv_library}) and also
Shark machine learning library (\cite{shark_library}) are available. Both
supervised and unsupervised classifiers are supported in the framework.

The current list of classifiers available through the same generic interface within the OTB is:

\begin{itemize}
  \item \textbf{LibSVM}: Support Vector Machines classifier based on libSVM.
  \item \textbf{SVM}: Support Vector Machines classifier based on OpenCV, itself based on libSVM.
  \item \textbf{Bayes}: Normal Bayes classifier based on OpenCV.
  \item \textbf{Boost}: Boost classifier based on OpenCV.
  \item \textbf{DT}: Decision Tree classifier based on OpenCV.
  \item \textbf{RF}: Random Forests classifier based on the Random Trees in OpenCV.
  \item \textbf{GBT}: Gradient Boosted Tree classifier based on OpenCV (removed in version 3).
  \item \textbf{KNN}: K-Nearest Neighbors classifier based on OpenCV.
  \item \textbf{ANN}: Artificial Neural Network classifier based on OpenCV.
  \item \textbf{SharkRF} : Random Forests classifier based on Shark.
  \item \textbf{SharkKM} : KMeans unsupervised classifier based on Shark.
\end{itemize}

These models have a common interface, with the following major functions:
\begin{itemize}
  \item \code{SetInputListSample(InputListSampleType *in)} : set the list of input samples
  \item \code{SetTargetListSample(TargetListSampleType *in)} : set the list of target samples
  \item \code{Train()} : train the model based on input samples
  \item \code{Save(...)} : saves the model to file
  \item \code{Load(...)} : load a model from file
  \item \code{Predict(...)} : predict a target value for an input sample
  \item \code{PredictBatch(...)} : prediction on a list of input samples
\end{itemize}

The \code{PredictBatch(...)} function can be multi-threaded when
called either from a multi-threaded filter, or from a single location. In
the later case, it creates several threads using OpenMP.
There is a factory mechanism on top of the model class (see
\doxygen{otb}{MachineLearningModelFactory}). Given an input file,
the static function \code{CreateMachineLearningModel(...)} is able
to instantiate a model of the right type.

For unsupervised models, the target samples \textbf{still have to be set}. They
won't be used so you can fill a ListSample with zeros.

%-------------------------------------------------------------------------------
\subsection{Training a model}

The models are trained from a list of input samples, stored in a
\subdoxygen{itk}{Statistics}{ListSample}. For supervised classifiers, they
also need a list of targets associated to each input sample. Whatever the
source of samples, it has to be converted into a \code{ListSample} before
being fed into the model.

Then, model-specific parameters can be set. And finally, the \code{Train()}
method starts the learning step. Once the model is trained it can be saved
to file using the function \code{Save()}. The following examples show how
to do that.

\input{TrainMachineLearningModelFromSamplesExample.tex}

\input{TrainMachineLearningModelFromImagesExample.tex}

%-------------------------------------------------------------------------------
\subsection{Prediction of a model}

For the prediction step, the usual process is to:
\begin{itemize}
\item Load an existing model from a file.
\item Convert the data to predict into a \code{ListSample}.
\item Run the \code{PredictBatch(...)} function.
\end{itemize}

There is an image filter that perform this step on a whole image, supporting
streaming and multi-threading: \doxygen{otb}{ImageClassificationFilter}.

\ifitkFullVersion
\input{SupervisedImageClassificationExample.tex}
\fi

%-------------------------------------------------------------------------------
\subsection{Integration in applications}

The classifiers are integrated in several OTB Applications. There is a base
class that provides an easy access to all the classifiers:
\subdoxygen{otb}{Wrapper}{LearningApplicationBase}. As each machine learning
model has a specific set of parameters, the base class
\code{LearningApplicationBase} knows how to expose each type of classifier with
its dedicated parameters (a task that is a bit tedious so we want to implement
it only once). The \code{DoInit()} method creates a choice parameter named
\code{classifier} which contains the different supported classifiers along
with their parameters.

The function \code{Train(...)} provide an easy way to train the selected
classifier, with the corresponding parameters, and save the model to file.

On the other hand, the function \code{Classify(...)} allows to load a model
from file and apply it on a list of samples.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Supervised classification}

\subsection{Support Vector Machines}
\label{sec:SupportVectorMachines}

\subsubsection{SVM general description}
Kernel based learning methods in general and the Support Vector
Machines (SVM) in particular, have been introduced in the last years
in learning theory for classification and regression tasks,
\cite{vapnik}. SVM have been successfully applied to text
categorization, \cite{joachims}, and face recognition,
\cite{osuna}. Recently, they have been successfully used for the
classification of hyperspectral remote-sensing images, \cite{bruzzoneSVM}.

Simply stated, the approach consists in searching for the separating
surface between 2 classes by the determination of the subset of
training samples which best describes the boundary between the 2
classes. These samples are called support vectors and completely
define the classification system. In the case where the two classes are
nonlinearly separable, the method uses a kernel expansion in order to make
projections of the feature space onto higher dimensionality spaces
where the separation of the classes becomes linear.

\subsubsection{SVM mathematical formulation}

This subsection reminds the basic principles of SVM learning and
classification. A good tutorial on SVM can be found in, \cite{burges}.

We have $N$ samples represented by the couple $(y_i,\mathbf{x}_i),
i=1\ldots N$ where $y_i \in \{-1,+1\}$ is the class label and
$\mathbf{x}_i \in \mathbb{R}^n$ is the feature vector of dimension
$n$. A classifier is a function  $$f(\mathbf{x},\boldsymbol{\alpha}) :
\mathbf{x}\mapsto y$$ where $\boldsymbol{\alpha}$ are the classifier
parameters. The SVM finds the optimal separating hyperplane which
fulfills the following constraints :
    \begin{itemize}
      \item The samples with labels $+1$ and $-1$ are on different
      sides of the hyperplane.
      \item The distance of the closest vectors to the hyperplane is
      maximised. These are the support vectors (SV) and this distance is
      called the margin.
    \end{itemize}

    The separating hyperplane has the equation
    $$\mathbf{w}\cdot\mathbf{x}+b=0;$$ with $\mathbf{w}$ being its
    normal vector and $x$ being any point of the hyperplane. The
    orthogonal distance to the origin is given by
    $\frac{|b|}{\|\mathbf{w}\|}$. Vectors located outside the
    hyperplane have either $\mathbf{w}\cdot\mathbf{x}+b>0$ or
      $\mathbf{w}\cdot\mathbf{x}+b<0$.

    Therefore, the classifier function can be written as
    $$f(\mathbf{x},\mathbf{w}, b)=sgn(\mathbf{w}\cdot\mathbf{x}+b).$$

The SVs are placed on two hyperplanes which are parallel to the
      optimal separating one. In order to find the optimal
      hyperplane, one sets $\mathbf{w}$ and
      $b$ : $$\mathbf{w}\cdot\mathbf{x}+b=\pm 1.$$

Since there must not be any vector inside the margin, the following
constraint can be used:
    $$\mathbf{w}\cdot\mathbf{x}_i+b\ge +1\text{ if }y_i=+1;$$
    $$\mathbf{w}\cdot\mathbf{x}_i+b\le -1\text{ if }y_i=-1;$$ which
    can be rewritten as $$y_i(\mathbf{w}\cdot\mathbf{x}_i+b)-1\ge 0~  ~ \forall i.$$

    The orthogonal distances of the 2 parallel hyperplanes to the
    origin are $\frac{|1-b|}{\|\mathbf{w}\|}$ and
      $\frac{|-1-b|}{\|\mathbf{w}\|}$. Therefore the modulus of the
    margin is equal to $\frac{2}{\|\mathbf{w}\|}$ and it has to be
    maximised.

    Thus, the problem to be solved is:

	\begin{itemize}
	\item Find $\mathbf{w}$ and $b$ which minimise
	 $\left\{ \frac{1}{2}\|\mathbf{w}\|^2 \right\}$
	\item under the constraint :
	 $y_i(\mathbf{w}\cdot\mathbf{x}_i+b)\ge 1~  ~ i=1\ldots N.$
	\end{itemize}

	This problem can be solved by using the Lagrange multipliers
	with one multiplier per sample. It can be shown that only the
	support vectors will have a positive Lagrange multiplier.

	In the case where the two classes are not exactly linearly
	separable, one can modify the constraints above by using
      $$\mathbf{w}\cdot\mathbf{x}_i+b\ge +1 - \xi_i \text{ if }y_i=+1;$$
    $$\mathbf{w}\cdot\mathbf{x}_i+b\le -1+\xi_i \text{ if }y_i=-1;$$
    $$\xi_i\ge 0~  ~\forall i.$$

	If $\xi_i > 1$, one considers that the sample is wrong. The
	function which has then to be minimised is
	$\frac{1}{2}\|\mathbf{w}\|^2 + C\left( \sum_i \xi_i\right); $,
	where $C$ is a tolerance parameter. The optimisation problem
	is the same than in the linear case, but one multiplier has to
	be added for each new constraint $\xi_i\ge 0$.

	If the decision surface needs to be non-linear, this solution
	cannot be applied and the kernel approach has to be adopted.

One drawback of the SVM is that, in their basic version, they can only
solve two-class problems. Some works exist in the field of multi-class
SVM (see \cite{allwein00reducing,weston98multiclass}, and the
comparison made by \cite{hsu01comparison}), but they are
not used in our system.

You have to be aware that to achieve better convergence of the algorithm it is
strongly advised to normalize feature vector components in the $[-1;1]$
interval.

For problems with $N > 2$ classes, one can choose either to train $N$
SVM (one class against all the others), or to train $N\times(N-1)$ SVM
(one class against each of the others). In the second approach, which
is the one that we use, the final decision is taken by choosing the
class which is most often selected by the whole set of SVM.

%-------------------------------------------------------------------------------
\subsection{Shark Random Forests}

The Random Forests algorithm is also available in OTB machine learning
framework. This model builds a set of decision trees. Each tree may not give
a reliable prediction, but taking them together, they form a robust classifier.
The prediction of this model is the mode of the predictions of individual trees.

There are two implementations: one in OpenCV and the other on in
Shark. The Shark implementation has a noteworthy advantage: the training step
is parallel. It uses the following parameters:
\begin{itemize}
\item The number of trees to train
\item The number of random attributes to investigate at each node
\item The maximum node size to decide a split
\item The ratio of the original training dataset to use as the out of bag sample
\end{itemize}

Except these specific parameter, its usage is exactly the same as the other
machine learning models (such as the SVM model).

%-------------------------------------------------------------------------------
\subsection{Generic Kernel SVM (deprecated)}
OTB has developed a specific interface for user-defined kernels. However, the
following functions use a deprecated OTB interface. The code source for these
Generic Kernels has been removed from the official repository. It is now
available as a remote module: \href{https://github.com/jmichel-otb/GKSVM}{GKSVM}.

A function $k(\cdot,\cdot)$ is considered to be a kernel when:
\begin{align}\label{eqMercer}
        \forall g(\cdot) \in {\cal L}^2(\mathbbm{R}^n) \quad & \text{so
that} \quad
        \int g(\boldsymbol{x})^2 d\boldsymbol{x} \text{ be finite,} \\
        & \text{then} \quad \int k(\boldsymbol{x},\boldsymbol{y}) \,
g(\boldsymbol{x})
        \, g(\boldsymbol{y}) \, d\boldsymbol{x} d\boldsymbol{y} \geqslant 0,
        \notag
\end{align}
which is known as the {\em Mercer condition\/}.

When defined through the OTB, a kernel is a class that inherits from
\code{GenericKernelFunctorBase}. Several virtual functions have to
be overloaded:
\begin{itemize}
\item The \code{Evaluate} function, which implements the behavior of the
kernel
itself. For instance, the classical linear kernel could be re-implemented
with:
\begin{verbatim}
        double
        MyOwnNewKernel
        ::Evaluate ( const svm_node * x, const svm_node * y,
                     const svm_parameter & param ) const
        {
                return this->dot(x,y);
        }
\end{verbatim}
This simple example shows that the classical dot product is already
implemented
into \code{otb::GenericKernelFunctorBase::dot()} as a protected
function.
\item The \code{Update()} function which synchronizes local variables and
their
integration into the initial SVM procedure. The following examples will show
the way to use it.
\end{itemize}

Some pre-defined generic kernels have already been implemented in OTB:
\begin{itemize}
\item \code{otb::MixturePolyRBFKernelFunctor} which implements a
linear mixture
of a polynomial and a RBF kernel;
\item \code{otb::NonGaussianRBFKernelFunctor} which implements a non
gaussian RBF kernel;
\item \code{otb::SpectralAngleKernelFunctor}, a kernel that integrates
the Spectral Angle, instead of the Euclidean distance, into an inverse
multiquadric kernel.
This kernel may be appropriated when using multispectral data.
\item \code{otb::ChangeProfileKernelFunctor}, a kernel which is
dedicated to the supervized classification of the multiscale change profile
presented in section \ref{sec:KullbackLeiblerProfile}.
\end{itemize}

\subsubsection{Learning with User Defined Kernels}
\label{sec:Learningwithuserdefinedkernel}
\ifitkFullVersion
\input{SVMGenericKernelImageModelEstimatorExample.tex}
\fi

\subsubsection{Classification with user defined kernel}

\ifitkFullVersion
\input{SVMGenericKernelImageClassificationExample.tex}
\fi

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Unsupervised classification}

\subsection{K-Means Classification}
\label{sec:KMeansClassifier}

\subsubsection{Shark version}

The KMeans algorithm has been implemented in Shark library, and has been
wrapped in the OTB machine learning framework. It is the first unsupervised
algorithm in this framework. It can be used in the same way as other machine
learning models. Remember that even if unsupervised model don't use a label
information on the samples, the target ListSample still has to be set in
\code{MachineLearningModel}. A ListSample filled with zeros can be used.

This model uses a hard clustering model with the following parameters:
\begin{itemize}
\item The maximum number of iterations
\item The number of centroids (K)
\item An option to normalize input samples
\end{itemize}

As with Shark Random Forests, the training step is parallel.

\subsubsection{Simple version}
\ifitkFullVersion
\input{ScalarImageKmeansClassifier.tex}
\fi
\ifitkFullVersion
\input{ScalarImageKmeansModelEstimator.tex}
\fi

\subsubsection{General approach}
\ifitkFullVersion
\input{KMeansImageClassificationExample.tex}
\fi

\subsubsection{k-d Tree Based k-Means Clustering}
\label{sec:KdTreeBasedKMeansClustering}
\ifitkFullVersion
\input{KdTreeBasedKMeansClustering.tex}
\fi
%-------------------------------------------------------------------------------
\subsection{Kohonen's Self Organizing Map}
\label{sec:SOM}
\input{Kohonen}
%%%1. Construction SOM
\subsubsection{Building a color table}
\label{sec:SOMColorTable}
\input{SOMExample}
\subsubsection{SOM Classification}
\label{sec:SOMClassification}
\input{SOMClassifierExample}

\subsubsection{Multi-band, streamed classification}

\ifitkFullVersion
\input{SOMImageClassificationExample.tex}
\fi

%%%2. Lecture SOM et ensemble de vecteurs autre image pour construire
%%%ActivationMAP

%\subsection{Bayesian classification}
%-------------------------------------------------------------------------------
\subsection{Bayesian Plug-In Classifier}
\label{sec:BayesianPluginClassifier}

\ifitkFullVersion
\input{BayesianPluginClassifier.tex}
\fi

%-------------------------------------------------------------------------------
\subsection{Expectation Maximization Mixture Model Estimation}
\label{sec:ExpectationMaximizationMixtureModelEstimation}

\ifitkFullVersion
\input{ExpectationMaximizationMixtureModelEstimator.tex}
\fi

%-------------------------------------------------------------------------------
\subsection{Statistical Segmentations}
\label{sec:StatisticalSegmentations}

%\subsection{Markov Random Fields}

\subsubsection{Stochastic Expectation Maximization}
\label{sec:SEM}

The Stochastic Expectation Maximization (SEM) approach is a stochastic
version of the EM mixture estimation seen on
section~\ref{sec:ExpectationMaximizationMixtureModelEstimation}. It has been
introduced by \cite{CeDi95} to prevent convergence of the EM approach from
local minima. It avoids the analytical maximization issued by integrating a
stochastic sampling procedure in the estimation process. It induces an almost
sure (a.s.) convergence to the algorithm.

From the initial two step formulation of the EM mixture estimation, the SEM
may be decomposed into 3 steps:
\begin{enumerate}
\item \textbf{E-step}, calculates the expected membership values for each
measurement vector to each classes.
\item \textbf{S-step}, performs a stochastic sampling of the membership vector
to each classes, according to the membership values computed in the E-step.
\item \textbf{M-step}, updates the parameters of the membership probabilities
(parameters to be defined through the class
\subdoxygen{itk}{Statistics}{ModelComponentBase} and its inherited classes).
\end{enumerate}
The implementation of the SEM has been turned to a contextual SEM in the sense
where the evaluation of the membership parameters is conditioned to
membership values of the spatial neighborhood of each pixels.

\ifitkFullVersion
\input{SEMModelEstimatorExample.tex}
\fi

%-------------------------------------------------------------------------------
\subsection{Classification using Markov Random Fields}
\label{sec:MarkovRandomField}

Markov Random Fields are probabilistic models that use the statistical
dependency between
pixels in a neighborhood to infeer the value of a give pixel.

\subsubsection{ITK framework}
\label{sec:MarkovRandomFieldITK}
The
\subdoxygen{itk}{Statistics}{MRFImageFilter} uses the maximum a posteriori (MAP)
estimates for modeling the MRF. The object traverses the data set and uses the
model generated by the Mahalanobis distance classifier to get the the distance
between each pixel in the data set to a set of known classes, updates the
distances by evaluating the influence of its neighboring pixels (based on a MRF
model) and finally, classifies each pixel to the class which has the minimum
distance to that pixel (taking the neighborhood influence under consideration).
The energy function minimization is done using the iterated conditional modes
(ICM) algorithm \cite{Besag1986}.

\ifitkFullVersion
\input{ScalarImageMarkovRandomField1.tex}
\fi

\subsubsection{OTB framework}
\label{sec:MarkovRandomFieldOTB}
The ITK approach was considered not to be flexible enough for some
remote sensing applications. Therefore, we decided to implement our
own framework.
\index{Markov}

\begin{figure}[th]
  \centering
  \includegraphics[width=0.7\textwidth]{MarkovFramework.eps}
  \itkcaption[OTB Markov Framework]{OTB Markov Framework.}
  \label{fig:markovFramework}
\end{figure}

\index{Markov!Classification}
\ifitkFullVersion
\input{MarkovClassification1Example.tex}
\fi

\index{Markov!Classification}
\ifitkFullVersion
\input{MarkovClassification2Example.tex}
\fi

\index{Markov!Classification}
\ifitkFullVersion
\input{MarkovClassification3Example.tex}
\fi

\index{Markov!Regularization}
\ifitkFullVersion
\input{MarkovRegularizationExample.tex}
\fi

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Fusion of Classification maps}

\subsection{General approach of image fusion}
In order to obtain a relevant image classification it is sometimes necessary to
fuse several classification maps coming from different classification methods
(SVM, KNN, Random Forest, Artificial Neural Networks,...). The fusion of
classification maps combines them in a more robust and precise one. Two methods are
available in the OTB: the majority voting and the Demspter Shafer framework.

%-------------------------------------------------------------------------------
\subsection{Majority voting}
\subsubsection{General description}
For each input pixel, the Majority Voting method consists in choosing the more
frequent class label among all classification maps to fuse. In case of not unique
more frequent class labels, the undecided value is set for such pixels in
the fused output image.

\subsubsection{An example of majority voting fusion}
\ifitkFullVersion
\input{MajorityVotingFusionOfClassificationMapsExample.tex}
\fi

%-------------------------------------------------------------------------------
\subsection{Dempster Shafer}

\subsubsection{General description}
A more adaptive fusion method using the Dempster Shafer theory
(\href{http://en.wikipedia.org/wiki/Dempster-Shafer_theory}{http://en.wikipedia.org/wiki/Dempster-Shafer\_theory})
is available within the OTB. This method is adaptive as it is based on the
so-called belief function of each class label for each classification map. Thus,
each classified pixel is associated to a degree of confidence according to the
classifier used. In the Dempster Shafer framework, the expert's point of view
(i.e. with a high belief function) is considered as the truth. In order to
estimate the belief function of each class label, we use the Dempster Shafer
combination of masses of belief for each class label and for each classification
map. In this framework, the output fused label of each pixel is the one with the
maximal belief function.

Like for the majority voting method, the Dempster Shafer fusion handles not
unique class labels with the maximal belief function. In this case, the output
fused pixels are set to the undecided value.

The confidence levels of all the class labels are estimated from a comparison of
the classification maps to fuse with a ground truth, which results in a
confusion matrix. For each classification maps, these confusion matrices are then
used to estimate the mass of belief of each class label.

\subsubsection{Mathematical formulation of the combination algorithm}

A description of the mathematical formulation of the Dempster Shafer combination
algorithm is available in the following OTB Wiki page:
\href{http://wiki.orfeo-toolbox.org/index.php/Information_fusion_framework}{http://wiki.orfeo-toolbox.org/index.php/Information\_fusion\_framework}.

\subsubsection{An example of Dempster Shafer fusion}
\ifitkFullVersion
\input{DempsterShaferFusionOfClassificationMapsExample.tex}
\fi

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Classification map regularization}

%\subsection{Regularization by neighborhood-based majority voting}

\ifitkFullVersion
\input{ClassificationMapRegularizationExample.tex}
\fi


\documentclass{article}
\usepackage{leonine,amsmath,amssymb,amsthm,graphicx}
\setkeys{Gin}{width=\linewidth,totalheight=\textheight,keepaspectratio}
\graphicspath{{graphics/}}
% Prints a trailing space in a smart way.
\usepackage{xspace}
% Inserts a blank page
\newcommand{\blankpage}{\newpage\hbox{}\thispagestyle{empty}\newpage}
% \usepackage{units}
% Typesets the font size, leading, and measure in the form of 10/12x26 pc.
\newcommand{\measure}[3]{#1/#2$\times$\unit[#3]{pc}}

\theoremstyle{definition}
\newtheorem{pred}[thm]{Prediction}

\title{Askesis: Negative Pathway 2} \author{Eric Purdy}

\begin{document}

\maketitle
\section{Overview}

The purpose of the negative pathway is to filter out potential
movements produced by the positive pathway, leaving only the desired
movements as output from the deep nuclear cells. Our theory of the
negative pathway is very similar to the perceptron model of Albus,
although we modify the input to each perceptron slightly.

\section{Purkinje Cells and Basket Cells}
\label{sec-purkinje}

Let $G_i(t)$ be the firing of the $i$-th granular cell at time $t$.

We model the basket cell as
$$B_j(t) = \sigma \left(\sum_i W^-_{ij} G_i(t) +\theta^-_j \right).$$

We model the Purkinje cell as
$$P_j(t) = \sigma \left(\sum_i W^+_{ij} G_i(t) +\theta^+_j - \alpha B_j(t) \right).$$

We will use a simpler model for the combined basket cell-Purkinje cell
pair:
\begin{align*}
P_j(t) &= \sigma \left(\sum_i (W^+_{ij}-W^-_{ij}) G_i(t) + (\theta^+_j
- \theta^-_j)\right)\\ &= \sigma \left(\sum_i W_{ij} G_i(t) +\theta_j \right),
\end{align*}
where the $W_{ij}$ and $\theta_j$ are free to take on both positive
and negative values.

Let $y_j(t)$ be $1$ if the $j$-th inferior olive cell fires at time
$t$, and $-1$ otherwise. We assume that the inferior olive cells are
in one-to-one correspondence to the Purkinje cells, which is a slight
simplification.

In order to best set the weights $W_{ij}$ and bias $\theta_j$ of the
$j$-th Purkinje cell, we minimize the following function:
$$L(\{W_{ij}\}, \{\theta_j\}) = \sum_t y_j(t) \left(W_{ij} G_i(t) +
\theta_j\right) + \lambda \sum_i W_{ij}^2. $$
This rewards us for having the Purkinje cell activation ($W_{ij}
G_i(t) + \theta_j$) low when the climbing fiber is active
($y_j(t)=1$), and for having the Purkinje cell activation high when
the climbing fiber is inactive ($y_j(t)=-1$). Since the Purkinje cell
suppresses the corresponding deep nuclear cell, and the climbing fiber
encodes the information that we want the corresponding deep nuclear
cell to fire, this is the desired behavior.

The term $\lambda \sum_i W_{ij}^2$ is necessary to prevent the weights
from increasing without bound. It favors parameter settings with
smaller weights, which are thought of as being ``simpler'' in the
machine learning literature; favoring smaller weights is thus a form
of Occam's Razor. The constant multiplier $\lambda$ controls the
tradeoff between this term and the other term. The larger $\lambda$
is, the more the algorithm will favor model simplicity (small weights)
over fitting the data well.

This can be compared with the support vector machine (SVM), an
algorithm that minimizes the following function:
$$L(\{W_{ij}\}, \{\theta_j\}) = \sum_t \left[ 1+y(t)\left(\sum_i
  W_{ij} G_i(t) + \theta_j\right)\right]_+ + \lambda \sum_i
W_{ij}^2,$$ where $[a]_+$ is zero if $a$ is negative, and
equal to $a$ otherwise. The difference between the two is that
the SVM uses the ``hinge loss'' while we are simply using a linear
loss function. This difference means that we get extra credit for
being more certain that we are right; with the hinge loss, we are
penalized a lot when we are certain but wrong, but not rewarded for
being more certain when we are right. These loss functions, as well as
the step loss function, are shown in Figure \ref{fig-hinge}; the hinge
loss is a sort of combination of the step loss function and the linear
loss function.

\begin{figure}
\includegraphics[width=0.3\linewidth]{step_loss.png}
\includegraphics[width=0.3\linewidth]{linear_loss.png}
\includegraphics[width=0.3\linewidth]{hinge_loss.png}
\caption{Various loss functions: the step loss function, the linear loss function, and the hinge loss function.}
\label{fig-hinge}
\end{figure}

The partial derivatives are:
\begin{align*}
\frac{\partial L(W)}{\partial W_{ij}} &= \sum_t y(t) G_i(t) + 2\lambda W_{ij}\\
\frac{\partial L(W)}{\partial \theta_j} &= \sum_t y(t).\\
\end{align*}
Using stochastic gradient descent (since we want to minimize
$L(\{W_{ij}\}, \{\theta_j\})$), this leads to the update rules
\begin{align*}
\Delta W_{ij} &= -\eta y_j(t) G_i(t) - \frac{2\eta\lambda}{T} W_{ij}\\
\Delta \theta_j &= -\eta y_j(t). \\
\end{align*}
We apply this to the actual synapse weights and cell biases by adding
$\frac{1}{2}\Delta W_{ij}$ to the weight $W^+_{ij}$ and
$-\frac{1}{2}\Delta W_{ij}$ to the weight $W^-_{ij}$, and adding
$\frac{1}{2}\Delta \theta_j$ to $\theta^+_j$ and adding
$-\frac{1}{2}\Delta \theta_j$ to $\theta^-_j$. This is consistent with
the observed learning behavior at the parallel fiber-Purkinje cell
synapse and the parallel fiber-basket cell synapse:
\begin{itemize}
\item LTD at the parallel fiber-Purkinje cell synapse when the
  inferior olive cell fires at the same time as the parallel fiber
  ($y_j(t)=1, G_i(t)=1$)
\item LTP at the parallel fiber-Purkinje cell synapse when the
  parallel fiber fires but the inferior olive cell does not
  ($y_j(t)=-1, G_i(t)=1$)
\item LTP at the parallel fiber-basket cell synapse when the inferior
  olive cell fires at the same time as the parallel fiber ($y_j(t)=1,
  G_i(t)=1$)
\item LTD at the parallel fiber-basket cell synapse when the parallel
  fiber fires but the inferior olive cell does not ($y_j(t)=-1,
  G_i(t)=1$)
\item No change when the parallel fiber is inactive ($G_i(t)=0$)
\end{itemize}
We also predict an exponential decay of the weights at both types of
synapse, as well as changes in the intrinsic excitability of the
basket cells and Purkinje cells corresponding to the change in
$\theta^-_j$ and $\theta^+_j$, respectively. The exponential decay
would contribute to memories in the negative pathway being short-lived
relative to memories in the positive pathway, which seems to be the
case.

We have phrased these as if the climbing fiber and parallel fiber
activations should be synchronized, but learning is observed to be
maximized then there is a delay on the order of 100 milliseconds
between the activation of the parallel fiber and the activation of the
climbing fiber. This makes sense: the climbing fiber is activated by
slower, non-cerebellar networks, so its input will always arrive
delayed relative to the relevant stimuli reaching the Purkinje and
basket cells.

\subsection{Symmetry-breaking mechanism for the Purkinje cells}

Each Purkinje cell receives as input, in addition to its input from
the parallel fibers, collaterals from several nearby granular
cells. This input is weighted more highly than that at the parallel
fiber-Purkinje cell synapse. We posit that these collaterals exist to
break the symmetry between Purkinje cells that project to the same
deep nuclear cell, so that we can learn multiple different
classifiers, each of which is capable of suppressing the deep nuclear
cell. Otherwise, adjacent Purkinje cells would receive the same input.
(Recall that nearby inferior olive cells tend to be coupled with gap
junctions, so that the input from the inferior olive would also be the
same for each Purkinje cell.)

\end{document}


\subsection{Late Move Reductions (LMR)}

\subsubsection{Introduction}

If the tree is explored in an efficient order alpha-beta pruning is more effective.


%!TEX root = vorlage.tex

\subsection{Base line experiments}\label{sec:ap3}

The most basic information for pixel-wise semantic segmentation is the color of
the pixel. Typically, images are in RGB format. This means the image has
three~channels ({\color{red} R}ed, {\color{green} G}reen, {\color{blue} B}lue).
Each channel has 8~bit and thus $2^8 = 256$ possible values, ranging from 0 to
255. This gives ${(2^8)}^3 = \num{16777216}$ possible colors for each pixel.
Obviously, only the color can not give a perfect result in all circumstances as
the measured color changes due to smoke, shadows, specular~highlights and
insufficient illumination. But it gives an impression how important local
features are for the specific problem.

A model with 64~sigmoid nodes in a first hidden layer with $\SI{50}{\percent}$
dropout~\cite{srivastava2014dropout}, 64~ReLu nodes in a second hidden layer
with $\SI{50}{\percent}$ dropout and one sigmoid output unit was used as a
baseline.

The architecture of the baseline model is visualized
in~\cref{fig:baseline-architecture}. Neither preprocessing nor data
augmentation were applied.

The baseline model achieved a pixel-wise accuracy
of~$\SI{92.88}{\percent}$,\footnote{This is the same as the DICE coefficient.}
a precision of $\SI{76.13}{\percent}$ and a recall of $\SI{32.94}{\percent}$.
The confusion matrix is given in~\cref{table:cm-model-301}.

\begin{figure}[ht]
    \centering
    \input{mlp-architecture}
    \caption{Architecture of the baseline model.}
    \label{fig:baseline-architecture}
\end{figure}


\documentclass{scrartcl}
\usepackage[a4paper,left=1in,right=1in,top=1.2in,bottom=1in]{geometry}
\usepackage{siunitx}
\usepackage{graphicx}
\setkomafont{disposition}{\normalfont\bfseries}
\usepackage{amsmath}
\usepackage{easytable}
\usepackage{lipsum}
\usepackage{ragged2e}
\allowdisplaybreaks

%title
\title{Extra assignment:\\Inference for continuous detection and discrimination}
\subtitle{Theoretical Neuroscience II}
\author{Johannes G\"atjen}

\begin{document}
\maketitle

\section{Maximum joint density/probability}
\label{maxes}

I determined the peak density of the joint probability density function with three different computational methods.\footnote{I also tried to derive the maximum directly (analytically) from the probability density function, but gave up after still getting apparently wrong results after multiple attempts. One result included $c_s = -c_0$, another gave $x_k = \sqrt{\frac{1}{2\pi}}, \theta_s = \theta_k, c_s= \frac{c_0}{2} + \sqrt{\frac{c_0^2}{4}+\frac{c_0}{8e^2}}$} The results are summed up in the following table. For the first method, I wrote a function that evaluates the pdf directly and used a library function to iteratively find the maximum. For the second method I sampled the same function at fixed points at linearly spaced values for $\theta_k$ and logarithmically spaced values for $x_k$ and $c_s$, and selected the maximum from those results. Transforming the density function into a probability function, I also obtained an analytic result for the peak (discretized) probability. Lastly I generated stimuli and responses according to the probability distributions and calculated the empirical/numerical peak density and probability from the results. The chosen parameters are $c_0 = 1$ and $\theta_k = 0$.

\centering
\begin{TAB}(r, 10pt, 20pt)[4pt]{cc|c|c|c}{c|ccc|cc}
& \textbf{Method} & $\mathbf{x_k}$ & $\mathbf{c_s}$ & $\mathbf{\theta_s}$ \\
\textbf{peak density}	& direct optimization	& $\approx\num{1e-100}$ & $\approx\num{1e-100}$ & $\approx 3.7$ \\
& analytic & \num{1e-8} & \num{2e-8} & 2 \\
& numeric & 0 & \num{3e-8}  & 3.7\\
\textbf{peak probability}& analytic & 10 & 1 & 0 \\
& numeric & 7.3 & 0.65 & 0 \\
\end{TAB}

\justify
The results for the location of the peak probability do not agree closely for the response and contrast, but are within an order of magnitude. Since they are on a logarithmic scale, we cannot expect much better.

The results for the peak density show $x_k$ and $c_s$ close to zero. However the density function with $x_k = 0$ is equal to zero (so not maximal), and it is not defined for $c_s = 0$. The response rate $x_k$ is Rayleigh distributed with a mean determined by the stimulus contrast $c_s$ and orientation $\theta_s$. The mean tends towards zero with $c_s$. A Rayleigh distribution with the mean tending towards zero degenerates into a Dirac delta function $\operatorname{\delta}(x - \epsilon)$. This means the density at that point tends to infinity.

\section{Marginal response distribution}

Figure \ref{margs} shows the marginal distribution of the response rate, once derived analytically, once numerically, as described in Section \ref{maxes}. Qualitatively the analytic and numeric solutions agree well. The absolute values for the numeric solution are a bit smaller than for the analytic solution.

\begin{figure}[h]
\centering
\includegraphics[width=0.47\textwidth, clip]{../pics/s2/margXProb_analytic_final}
\includegraphics[width=0.47\textwidth, clip]{../pics/s2/margXProb_numeric_final} \\
\includegraphics[width=0.47\textwidth, clip]{../pics/s2/margXDens_analytic_final}
\includegraphics[width=0.47\textwidth, clip]{../pics/s2/margXDens_numeric_final}\\
\includegraphics[width=0.47\textwidth, clip]{../pics/s2/margXLogDens_analytic_final}
\includegraphics[width=0.47\textwidth, clip]{../pics/s2/margXLogDens_numeric_final}\\
\caption{Left column: Analytic solution. Right column: Numeric solution. Rows, top to bottom: Marginal (disrcretized) probability with logarithmically spaced values of $x$, marginal probability density, log of marginal probability density.}
\label{margs}
\end{figure}

\section{Posterior of contrast and orientation, given response}

Figure \ref{posts} shows the posterior probability of contrast and orientation, given a response rate. For low response rates the most likely stimulus is of non-preferred orientation, and has a higher contrast than the most likely stimulus with the preferred orientation. For higher response rates the posterior for the preferred stimulus orientation is highest.

\begin{figure}[h]
\centering
\includegraphics[width=0.49\textwidth, clip]{../pics/post_analytic_lowresp}
\includegraphics[width=0.49\textwidth, clip]{../pics/post_numeric_lowresp} \\
\includegraphics[width=0.49\textwidth, clip]{../pics/post_analytic_highresp}
\includegraphics[width=0.49\textwidth, clip]{../pics/post_numeric_highresp}\\
\caption{Left column: Analytic solution. Right column: Numeric solution. Posterior distribution for $x_k=\num{6.7e-4}$ (top) and for $x_k=45.3$ (bottom). $c_0 = 1, \theta_k = 0$}
\label{posts}
\end{figure}

\section{Probability and latency of object detection}
\label{plat}
I estimated the probability and latency of correctly detecting an object as a function of object duration and contrast. For a given sequence of stimuli and their response rates and a fixed window size I determined the most likely stimulus for every time step. The differences between true and detected contrast and orientation were transformed to be in the range $\left[0, 1\right]$. For the orientation I used the function $\operatorname{f}(\theta_s, \theta_d) = \frac{- \cos{(\theta_s - \theta_d)} + 1}{2}$ and for the contrast the function $\operatorname{f}(c_s, c_d) = \lvert \operatorname{cdf}(c_s, c_0) - \operatorname{cdf}(c_d, c_0) \rvert $ where subscripts $s$ and $d$ refer to the stimulus and detected values respectively and cdf is the cumulative density function for the distribution of stimulus contrast. If the result of these functions was smaller than a given threshold for both contrast and orientation at at least one point in time the corresponding stimulus was said to be correctly detected and the latency was set to the difference between stimulus onset and first time of correct detection.

Some example results are shown in Figure \ref{funs}. Overall trends appear to be as follows: Very low contrast and very high contrast objects are more difficult to detect than objects with average contrast. The latency is more or less independent of contrast, except for very high contrasts, where the latency is higher. Latency of detection is close to the worst possible value for short stimuli and otherwise independendent of stimulus duration. Probability of detection is high for all stimuli longer than the window size, with perhaps a small positive correlation between object duration and detection probability. For objects with a shorter duration than the window size the probability of detection rises rapidly with a longer duration. See also Figure \ref{sect}.

%These results indicate that larger window sizes worsen detection performance. However this is only so because of the specific way of measuring the performance. Which stimulus is detected after a single correct inference is completely ignored. Because the variance of the inferred stimulus properties is larger for smaller window sizes, it is likelier to get the stimulus correct at least once, even if on average the error is larger.

\begin{figure}[h]
\centering
\includegraphics[width=0.47\textwidth, clip]{../pics/t4/latency_of_dur_4chans_1_8_8_01}
\includegraphics[width=0.47\textwidth, clip]{../pics/t4/latency_of_contr_4chans_1_8_8_01}\\
\includegraphics[width=0.47\textwidth, clip]{../pics/t4/prob_of_con_4chans_1_8_8_01}
\includegraphics[width=0.47\textwidth, clip]{../pics/t4/prob_of_dur_4chans_1_8_8_01}\\
\caption{Probability and latency of stimulus detection as functions of stimulus duration and contrast. Chosen parameters: $c_0 = 1, \tau_0 = 8$, integration window size $=8$, detection threshold $=0.1$, number of channels $=4$. The red line in the top left plot indicates the maximum possible latency. Points on the line mean that the stimulus was either not detected at all, or detected at the last point in time before the next stimulus began. Actual results can be slightly above the line because the results for multiple durations are put together. The mean of zero values was set to zero, which explains the zero points in the bottom right plot.}
\label{funs}
\end{figure}

\begin{figure}
\centering
\includegraphics[width=0.66\textwidth, clip]{../pics/t4/prob_of_dur_1_8_8_01_section}
\caption{Chosen parameters: $c_0 = 1, \tau_0 = 8$, integration window size $=8$, detection threshold $=0.1$, number of channels $=12$. Illustration of the initial rapid rise of detection probability for stimuli shorter than the window size. }
\label{sect}
\end{figure}

\section{Standard deviaton of error}

I estimated the precision of the inferred stimuli as a function of object duration and contrast with the standard deviation of the error. I generated stimuli, responses and inferred stimuli as described in Section \ref{plat}, but did not transform the difference into the $\left[0, 1\right]$ range. Some results are shown in Figure \ref{stds}.

Comparing window sizes of 1 and 8, with the mean duration $\tau_0$ also set to 1 or 8 show that the inference is more precise with the smaller window size. The dependence of orientation and contrast precision on object duration are basically identical. For the small window size there is no clear dependence between object duration and precision. For the longer window size there is a clear trend of higher precision for longer duration objects. The absolute standard deviation values are much higher than for the short window though, approaching the short window performance only for very long duration objects.

The orientation precision seems to be independent of object contrast for small window sizes, and much larger for long windows, except for very low and very high contrast objects.
The standard deviation of the contrast error grows with the object contrast for the short window, but is high for all object contrast values for the long window.

\begin{figure}[h]
\centering
\includegraphics[width=0.47\textwidth, clip]{../pics/t5/oridur_highnum_1_8_1_8}
\includegraphics[width=0.47\textwidth, clip]{../pics/t5/oridur_highnum_1_8_8_8}\\
\includegraphics[width=0.47\textwidth, clip]{../pics/t5/condur_highnum_1_8_1_8}
\includegraphics[width=0.47\textwidth, clip]{../pics/t5/condur_highnum_1_8_8_8}\\
\caption{Standard deviation of orientation and contrast error as functions of object duration. Chosen parameters: $c_0 = 1, \tau_0 = 8$, number of channels $=8$, left column integration window size $=1$, right column integration window size $=8$. Note the much larger scale of the y axis for the larger window size.}
\label{stds}
\end{figure}

\section{Optimal window size for parameters}

Finally I estimated the optimal window size for a given set of environment parameters $c_0$ and $\tau_0$. For the given parameters I generated stimuli and responses, and from the responses the inferred stimulus for different window sizes. As in Section \ref{plat} the difference of true and inferred stimulus contrast and orientation was transformed to the range $\left[0, 1\right]$ so that errors in estimated contrast and orientation would be weighted roughly equally. An exemplary result is shown in Figure \ref{optws}. We can see that with a higher $\tau_0$ longer window sizes are preferred. The relationship between contrast and optimal window size is unclear.

\begin{figure}[h]
\centering
\includegraphics[width=0.55\textwidth, clip]{../pics/optws_chan8}
\caption{The ``optimal'' window size as a function of environment parameters $c_0$ (contrast) and $\tau_0$ (duration), using 8 channels.}
\label{optws}
\end{figure}

%\begin{align*}
%r_k =& c_s \exp{(2 \cos{\theta_k-\theta_s)}}\\
%\ln{\operatorname{p}(x_k, c_s, \theta_s)} =&
%	\ln{\frac{\pi}{2} +
%	\ln{x_k} -
%	2 \ln{r_k} -
%	\frac{\pi x_k^2}{4r_k^2} -
%	\ln{2\pi} -
%	\frac{c_s}{c_0} -
%	\ln{c_0}}\\
%\operatorname{p} (x_k, c_s, \theta_s) =&
%	\frac{x_k r_k}{4 c_0} \cdot
%	\exp{\left(
%		-\frac{\pi x_k^2}{4r_k^2} -
%		\frac{c_s}{c_0} - 2
%		\right)}\\
%0 = \frac{\partial \operatorname{p} (x_k, c_s, \theta_s)}{\partial x_k} =&
%	\frac{r_k}{4c_0}
%	\exp{\left(
%		-x_k^2
%		\frac{\pi}{4r_k^2} -
%		\frac{c_s}{c_0} - 2
%		\right)} +
%	\frac{x_k r_k}{4c_0}
%	\frac{-2\pi x_k}{4r_k^2}
%	\exp{\left(
%		-x_k^2
%		\frac{\pi}{4r_k^2}
%		\right) }\\
%=& \underbrace{
%		\exp{\left(
%			-x_k^2
%			\frac{\pi}{4r_k^2}
%			\right)}
%		\frac{r_k}{4c_0}}_{\neq 0} \cdot
%	\left( 1 - 2\pi x_k^2 \right)\\
%x_k^2 =& \frac{1}{2\pi}\\
%x_k =& \sqrt{\frac{1}{2\pi}}\\ \\
%\operatorname{p}(\sqrt{1/2\pi}, c_s, \theta_s) =&
%	\frac{c_s
%		\exp{\left(
%			2 \cos{\theta_k - \theta_s}
%			\right)}}
%		{4c_0\sqrt{2\pi}} \cdot
%	 \exp{\left(
%	 	-\frac{1}{8c_s}
%	 	\exp{\left(
%	 		-2\cos{\theta_k - \theta_s}
%	 		\right)}-
%	 	\frac{c_s}{c_0}-2
%	 	\right)} \\
%0 = \frac{\partial \operatorname{p}(\sqrt{1/2\pi}, c_s, \theta_s)}{\partial \theta_s} =& \exp{\left(
%		-\frac{1}{8c_s}
%		\exp{\left(
%			-2\cos{\theta_k - \theta_s}
%			\right)} -
%		\frac{c_s}{c_0}-2
%		\right)} \cdot \\
%	&\frac{c_s
%		\exp{\left(
%			2 \cos{\theta_k - \theta_s}
%			\right)}}
%		{4c_0\sqrt{2\pi}}
%	\frac{2\sin{\theta_k-\theta_s}}{8c_s\exp{\left(
%		2\cos{\theta_k - \theta_s}
%		\right)}} \\
%+& \exp{\left(
%		-\frac{1}{8c_s}
%		\exp{\left(
%			-2\cos{\theta_k - \theta_s}
%			\right)} -
%		\frac{c_s}{c_0}-2
%		\right)} \cdot \\
%	 &\exp{\left(
%	 	2\cos{\theta_k - \theta_s}
%	 	\right)}
%	 \frac{2c_s\sin{\theta_k-\theta_s}}{4c_0\sqrt{2\pi}} \\
%=& \underbrace{\exp{\left(
%		-\frac{1}{8c_s}
%		\exp{\left(
%			-2\cos{\theta_k - \theta_s}
%			\right)} -
%		\frac{c_s}{c_0}-2
%		\right)}
%	\exp{(2\cos{\theta_k-\theta_s})}
%	\frac{2c_s}{4c_0\sqrt{2\pi}}}_{\neq 0} \cdot \\
%	&\sin{(\theta_k-\theta_s)}
%	\underbrace{\left(
%		\frac{1}{8c_s} \exp{(-2\cos{(\theta_k-\theta_s)})}
%		+1
%		\right)}_{\neq 0}\\
%0 =& \sin{\theta_k - \theta_s} \\
%\theta_s =& \theta_k \\ \\
%\operatorname{p}(\sqrt{1/2\pi}, c_s, \theta_k) =& \frac{c_s e^2}{4c_0 \sqrt{2\pi}}
%	\exp{\left(
%		-\frac{1}{8c_se^2} -
%		\frac{c_s}{c_0} - 2
%		\right)} \\
%0 = \frac{\partial \operatorname{p}(\sqrt{1/2\pi}, c_s, \theta_k)}{\partial c_s} =&
%	\frac{c_s e^2}{4c_0 \sqrt{2\pi}}
%	\exp{\left(
%		-\frac{1}{8c_se^2} -
%		\frac{c_s}{c_0} - 2
%		\right)}
%	\left(
%		-\frac{1}{c_0}
%		+ \frac{1}{8c_s^2e^2}
%		\right)	\\
%	+& \exp{\left(
%		-\frac{1}{8c_se^2} -
%		\frac{c_s}{c_0} - 2
%		\right)}
%	\frac{e^2}{4c_0\sqrt{2\pi}} \\
%=& \underbrace{\left(
%	\exp{\left(
%		-\frac{1}{8c_se^2} -
%		\frac{c_s}{c_0} - 2
%		\right)}
%	\frac{e^2}{4c_s\sqrt{2\pi}}
%	\right)}_{\neq 0} \cdot
%	\left(
%		\frac{1}{8c_se^2} - \frac{c_s}{c_0} + 1
%		\right)\\
%0 =& c_s^2 - c_sc_0 - \frac{c_0}{8e^2} \\
%c_s =& \frac{c_0}{2} +
%	\sqrt{
%		\frac{c_0^2}{4}+
%		\frac{c_0}{8e^2}}
%\end{align*}

\end{document}


\documentclass{article}
    % General document formatting
    \usepackage[margin=0.7in]{geometry}
    \usepackage[parfill]{parskip}
    \usepackage[utf8]{inputenc}
    \usepackage{amsmath}
    \usepackage{amssymb}
    \usepackage{tikz}
    \usepackage{fancyhdr}
    \usepackage{listings}

\pagestyle{fancy}
\fancyhf{}
\rhead{Edgar Jacob Rivera Rios - A01184125}

\begin{document}
\begin{titlepage}

    \newcommand{\HRule}{\rule{\linewidth}{0.5mm}} % Defines a new command for the horizontal lines, change thickness here

    \center % Center everything on the page

    %----------------------------------------------------------------------------------------
    %	HEADING SECTIONS
    %----------------------------------------------------------------------------------------

    \textsc{\LARGE Tecnológico de Monterrey}\\[1.5cm] % Name of your university/college
    \textsc{\Large Fundamentos de computación}\\[0.5cm] % Major heading such as course name
    %\textsc{\large Minor Heading}\\[0.5cm] % Minor heading such as course title

    %----------------------------------------------------------------------------------------
    %	TITLE SECTION
    %----------------------------------------------------------------------------------------

    \HRule \\[0.4cm]
    { \huge \bfseries Homework 2}\\[0.4cm] % Title of your document
    \HRule \\[1.5cm]

    %----------------------------------------------------------------------------------------
    %	AUTHOR SECTION
    %----------------------------------------------------------------------------------------

    \begin{minipage}{0.4\textwidth}
    \begin{flushleft} \large
    \emph{Student:}\\
    Jacob \textsc{Rivera} % Your name
    \end{flushleft}
    \end{minipage}
    ~
    \begin{minipage}{0.4\textwidth}
    \begin{flushright} \large
    \emph{Professor:} \\
    Dr. Hugo \textsc{Terashima} % Supervisor's Name
    \end{flushright}
    \end{minipage}\\[2cm]

    % If you don't want a supervisor, uncomment the two lines below and remove the section above
    %\Large \emph{Author:}\\
    %John \textsc{Smith}\\[3cm] % Your name

    %----------------------------------------------------------------------------------------
    %	DATE SECTION
    %----------------------------------------------------------------------------------------

    {\large \today}\\[2cm] % Date, change the \today to a set date if you want to be precise

    %----------------------------------------------------------------------------------------
    %	LOGO SECTION
    %----------------------------------------------------------------------------------------

    \includegraphics[width=0.4\textwidth,height=\textheight,keepaspectratio]{logo-tec-negro.png} % Include a department/university logo - this will require the graphicx package

    %----------------------------------------------------------------------------------------

    \vfill % Fill the rest of the page with whitespace

\end{titlepage}

\section{Problems}
Solve the following problems:
\begin{enumerate}
    \item Use  the  substitution  method  to  solve  the  following  recurrences  and  determine  their  corresponding complexity. Establish the proper initial conditions for each problem.
    \begin{enumerate}
        \item $T(n) = 4T(n/2) +n^4$
        \begin{equation*}
            T(n)=\begin{cases}
              b & \text{if $n = 1$}.\\
              aT(\frac{n}{c}) + bn^x, & \text{otherwise}.
            \end{cases}
        \end{equation*}
        \begin{equation*}
            n = 2^k
        \end{equation*}

        \begin{align*}
            T(n) &= 2^2T(n/2) + n^4\\
            &= 2^2(2^2T(\frac{n}{2^2}) + (\frac{n}{2})^4) + n^4\\
            &= 2^4(2^2T(\frac{n}{2^3}) + (\frac{n}{2^2})^4 )+ \frac{n^4}{2^2} + n^4\\
            &= 2^6(2^2T(\frac{n}{2^4}) + (\frac{n}{2^3})^4)+ \frac{n^4}{2^4} + \frac{n^4}{2^2} + n^4\\
            &= 2^8T(\frac{n}{2^4}) + \frac{n^4}{2^6}+ \frac{n^4}{2^4} + \frac{n^4}{2^2} + n^4\\
            &=2^{2k}T(\frac{n}{2^k}) +\sum^{k -1}_{i=0} \frac{n^4}{2^{2i}}\\
            &=2^{2k}T(\frac{n}{2^k}) +n^4 \sum^{k -1}_{i=0} \frac{1}{2^{2i}}\\
            &=2^{n}T(0) +n^4 \sum^{k -1}_{i=0} \frac{1}{2^{2i}}\\
            &=n^4 \sum^{k -1}_{i=0} \frac{1}{2^{2i}}\\
            &=n^4 \sum^{k -1}_{i=0} 2^{-2i}\\
            &=n^4 * \frac{1-2^k}{1-2}\\
            &=n^4\\
            &\in O(n^4)
        \end{align*}

        \item $T(n) = 3T(n/3) + n log(n)$
        \begin{equation*}
            n = 3^k
        \end{equation*}
        \begin{align*}
            T(n) &= 3T(n/3) + n log(n)\\
            &= 3(3T(\frac{n}{3^2}) + \frac{n}{3} log(\frac{n}{3})) + n log(n)\\
            &= 3^k T(\frac{n}{3^k}) + \sum_{i =0 }^{k-1} n log(\frac{n}{3^i})\\
            &= 3^k T(0) + \sum_{i =0 }^{k-1}n log(\frac{n}{3^i})\\
            &= n \sum_{i =0 }^{k-1} log(\frac{n}{3^i})\\
            &= n log^2(n) \\
            &\in n log^2(n)
        \end{align*}

        \item $T(n) = 3T(n/3) + \frac{\sqrt{n}}{log(n)}$
        \begin{equation*}
            n = 3^k
        \end{equation*}
        \begin{align*}
            T(n) &= 3T(n/3) + \frac{\sqrt{n}}{log(n)}\\
            &= 3(3T(\frac{n}{3^2}) + \frac{\sqrt{n/3}}{log(n/3)}) + \frac{\sqrt{n}}{log(n)}\\
            &= 3^2T(\frac{n}{3^2}) + 3\frac{\sqrt{n/3}}{log(n/3)}) + \frac{\sqrt{n}}{log(n)}\\
            &= 3^2(3T(\frac{n}{3^3}) + \frac{\sqrt{n/3}}{log(n/3)}) + 3\frac{\sqrt{n/3}}{log(n/3)} + \frac{\sqrt{n}}{log(n)}\\
            &= 3^3T(\frac{n}{3^3}) + 3^2\frac{\sqrt{n/3}}{log(n/3)} + 3\frac{\sqrt{n/3}}{log(n/3)} + \frac{\sqrt{n}}{log(n)}\\
            &= 3^kT(\frac{n}{3^k}) + \sum_{i =0}^{k-1}3^i\frac{\sqrt{n/3^i}}{log(n/3^i)} \\
            &= 3^kT(0) + \sum_{i =0}^{k-1}3^i\frac{\sqrt{n/3^i}}{log(n/3^i)}\\
            &= \sum_{i =0}^{k-1}3^i\frac{\sqrt{n/3^i}}{log(n/3^i)}\\
            &= \sum_{i =0}^{k-1}3^i\frac{\sqrt{n/3^i}}{log(n/3^i)} \leq 3^{log(n)}\\
            \in O(3^{log(n)})
        \end{align*}
        \item $T(n) = T(n - 3) +n$
        \begin{equation*}
            n = 3k
        \end{equation*}
        \begin{align*}
            T(n) &= T(n -3) + n\\
            T(n-1) &= T(n-4) + n\\
            T(n-3) &= T(n-6) + n\\
            &= T(n-6) + 2n\\
            &= T(n-3k) + kn\\
            &= T(n-3\frac{n}{3}) + \frac{n}{3}n\\
            &= T(0) + \frac{n}{3}n\\
            &= \frac{n^2}{3}\\
            &\in O(n^2)
        \end{align*}
    \end{enumerate}
    \item  Modify the algorithm for multiplying two numbers $X$ and $Y$(that with complexity $n^{1,59}$), dividing each number in three parts. Describe the algorithm and derive its complexity. Is it better than dividing by two parts? Explain.

    The algorithm would keep the same functioning as the old one, the only difference being how it's divided. As such, the recurrence would be

    \begin{align*}
        T(n) = 8T(n/3) + kn
    \end{align*}

    Which results in a complexity $O(n^{1.893})$ which would result in worst performance than using a two parts split

    \item The run time of an algorithm $A$ for solving a problem is given by the recurrence $T(n) = 7T(n/4) + n.$ A different algorithm $A^{\prime}$ for solving the same problem has a running time given by $T^{\prime}(n) =aT^{\prime}(n/7) +n$. Determine  the  integer  value $a$ with  which  algorithm $A$ is  better  than  algorithm $A^{\prime}$.  Explain  your process.

    By the use of the master theorem, we know that $T(n) \in O(n^{1.404})$ and $T'(n) \in O(n)$, so only when $n = 1$ the algorithms are going to make the same number of steps.

    \item For each of the following algorithms, which each receive an integer as input, determine what they do,establish the corresponding recurrence,and solve it to find the computational complexity.
    \begin{lstlisting}
    ALGORITHM BR(n)
        // Input a positive integer n
        if n = 1 return 1
        else return BR(floor(n/2)) + 1
    \end{lstlisting}

    This algorithm returns the power of 2 closest to the input number, without surpassing it. The recurrence would be: $T(n) = T(n/2) + 1$, which complexity would be $O(log(n))$

    \begin{lstlisting}
    ALGORITHM Question(n)
        // Input a positive integer n
        if n = 1 return 1
        else return Question(n-1) + n*n*n
    \end{lstlisting}

    This algorithm gives us the sum of the cubes of all numbers until n. As such, the recurrence would be $T(n) = T(n - 1) + n^3$, which results in complexity of $O(n^4)$
    \begin{align*}
        n = k
        T(n) &= T(n - 1) + n^3\\
        T(n - 1 ) &= T(n - 2) + 2n^3\\
        T(n) &= T(n - k) + kn^3\\
        T(n) &= T(0) + n^4\\
        \in O(n^4)
    \end{align*}

    \item The Towers of Hanoi problem is often used as an example when teaching recursion. Six disks of different sizes are piled on a peg in order by size, with the largest at the bottom. There are two empty pegs. The problem is to move all the disks to the third peg by moving only one at a time a never placing a disk on top of a smaller one. The second peg may be used for intermediate moves. The usual solution recursively moves all but the last disk from the starting peg to the spare peg, then moves the remaining disks on the start peg to the destination peg, and then recursively moves all the others from the spare peg to the destination peg. Illustrate these steps and explain the procedure in a pseudocode. Write a recurrence equation to determine the number of moves done and solve it.

    The solution proposed would be fairly easy to implement following the next pseudocode:
    \begin{lstlisting}
    Towers(disk, source, destination, auxiliar)
        //Disk is the number of the disk to be moved, source is the starting
        point, destination is the goal and auxiliar is the spare peg
        if (disk == 1)
            move(disk, destination)
        else
            Towers(n - 1, source, auxiliar, destination)
            move(disk, destination)
            Towers(n - 1, auxiliar, destination, source)
    \end{lstlisting}

    \begin{align*}
        T(1) &= 1\\
        n &= k +1\\
        T(n) &= 2T(n-1)\\
        &= 2^2T(n-2)\\
        &= 2^kT(n-k)\\
        &= 2^{n-1}T(n-(n -1))\\
        &= 2^{n-1}T(1)\\
        &= 2^{n-1}\\
        &\in \theta(2^{n-1})
    \end{align*}

\end{enumerate}
\end{document}


\section{Models}
\subsection{Sequence Graph}
A sequence graph is a hierarchy of directed acyclic dependence graphs with
dedicated start and end nodes. There are two kinds of nodes: task nodes and
hierarchy nodes (CALL for module calls, BR for branches, LOOP for iterations).

\subsubsection{Examples}

\begin{multicols}{2}
	\begin{lstlisting}
x = a * b;
y = x * c;
z = a + b;
submodule(a, z);

void submodule(int m, int n) {
	p = m + n;
	q = m * n;
}
	\end{lstlisting}
	\columnbreak
	\begin{tikzpicture}[node distance = 1.8cm]
		\node[nop]		(0)						{NOP};
		\node[inner]	(1)	[below left of=0]	{$\times$};
		\node[inner]	(2) [below of=1]		{$\times$};
		\node[inner]	(3) [below right of=0]	{$+$};
		\node[inner]	(4)	[below of=3]		{CALL};
		\node[nop]		(5) [below right of=2]	{NOP};
		\node[inner]	(7)	[below right of=4]	{$+$};
		\node[nop]		(6)	[above right of=7]	{NOP};
		\node[inner]	(8) [below right of=6]	{$\times$};
		\node[nop]		(9)	[below right of=7]	{NOP};

		\path	(0) edge[dashed]				(1)
				(0) edge[dashed]				(3)
				(1) edge[->]					(2)
				(2) edge[dashed]				(5)
				(3) edge[->]					(4)
				(4) edge[dashed]				(5)
				(4) edge[dashed, ->]			(6)
				(6) edge[dashed]				(7)
				(6) edge[dashed]				(8)
				(7) edge[dashed]				(9)
				(8) edge[dashed]				(9)
				(9) edge[dashed, ->, bend left]	(4)
		;
	\end{tikzpicture}
\end{multicols}

\begin{lstlisting}
x = a * b;
y = x * c;
z = a + b;

if (z > 0) {
	p = m + n;
	q = m * n;
}
\end{lstlisting}

\begin{tikzpicture}[node distance = 1.8cm]
	\node[nop]		(0)							{NOP};
	\node[inner]	(1)	[below left of=0]		{$\times$};
	\node[inner]	(2) [below of=1]			{$\times$};
	\node[inner]	(3) [below right of=0]		{$+$};
	\node[inner]	(4)	[below of=3]			{CALL};
	\node[nop]		(5) [below right of=2]		{NOP};

	\node[inner]	(7)		[below right of=4]	{$+$};
	\node[nop]		(6)		[above right of=7]	{NOP};
	\node[inner]	(8)		[below right of=6]	{$\times$};
	\node[nop]		(9)		[below right of=7]	{NOP};

	\node[nop]		(11)	[right of=8]		{NOP};
	\node[nop]		(10)	[above of=11]		{NOP};
	\node[nop]		(12)	[below of=11]		{NOP};

	\path	(0)		edge[dashed]					(1)
			(0)		edge[dashed]					(3)
			(1)		edge[->]						(2)
			(2)		edge[dashed]					(5)
			(3)		edge[->]						(4)
			(4)		edge[dashed]					(5)
			(4)		edge[dashed, ->]				(6)
			(6)		edge[dashed]					(7)
			(6)		edge[dashed]					(8)
			(7)		edge[dashed]					(9)
			(8)		edge[dashed]					(9)
			(9)		edge[dashed, ->, bend left]		(4)
			(4)		edge[dashed, ->, bend left] 	(10)
			(10)	edge[dashed, ->]				(11)
			(11)	edge[dashed, ->]				(12)
			(12)	edge[dashed, ->, bend left=60]	(4)
	;
\end{tikzpicture}


\newpage
\subsection{Goal}\label{subsec:goal}

The use of the network analysis software Gephi.

\subsection{Formulation of the problem}\label{subsec:formulation-of-the-problem}

\begin{enumerate}
    \item Download and install Gephi from \url{https://gephi.org/}.
    \item Choose a network dataset from \url{https://snap.stanford.edu/data/} with number of nodes at most 10,000.
    You are free to choose the network nature and type (un/weighted, un/directed).
    \item Change the format of the dataset for that accepted by Gephi (.csv, .xls, .edges, etc.), if necessary.
    \item Upload and process the dataset in Gephi. Check if the parameters of import and data are correct.
    \item Obtain a graph layout of two different types.
    \item Calculate available network measures in Statistics provided by Gephi.
    \item Analyze the results for the network chosen.
\end{enumerate}

While performing the work, screenshot the main steps you are doing and insert in the report.

\subsection{Brief theoretical part}\label{subsec:brief-theoretical-part}

\paragraph{Gephi.}

\textit{Gephi} is an interactive visualization and exploration platform for all kinds of networks and complex systems, dynamic and hierarchical graphs.

\paragraph{Dataset information.}

This is who-trusts-whom network of people who trade using Bitcoin on a platform called Bitcoin Alpha.
Since Bitcoin users are anonymous, there is a need to maintain a record of users' reputation to prevent transactions with fraudulent and risky users.
Members of Bitcoin Alpha rate other members in a scale of -10 (total distrust) to +10 (total trust) in steps of 1.
This is the first explicit weighted signed directed network available for research.

\paragraph{Dataset statistics:}
\begin{itemize}
    \item nodes: 3,783;
    \item edges: 24,186;
    \item range of edge weight: -10 to +10;
    \item percentage of positive edges: 93\%.
\end{itemize}

\paragraph{Main characteristics.}
Characteristics of degrees of vertices of an unweighted graph:
\begin{itemize}
    \item $d(v), \text{degree} v$, - number of incoming and outgoing edges of vertex $v$;
    \item $d_{in}(v), \text{half-step of approach} v$, - the number of incoming edges of vertex $v$;
    \item $\bar{d} = \frac{1}{\lvert V \rvert}\sum_{v \in V}{d(v)}$ - the average degree of vertices.
\end{itemize}

For a weighted graph, similar values can be entered, with the only difference that they do not take into account the number of edges, but the sum of the weights on the edges.

Graph characteristics in terms of distances:
\begin{itemize}
    \item $dist(v, u)$ - the distance between $v$ and $u$;
    \item \textit{eccentricity} $\epsilon(v) = \max_{u \in V}dist(v, u)$ - the greatest distance between $v$ and other vertexes;
    \item \textit{radius} $r = \min_{v \in V}\epsilon(v)$ - the minimum eccentricity across all vertices;
    \item \textit{diameter} $D = \max_{v \in V}\epsilon(v)$ - the highest eccentricity of all the nodes;
    \item \textit{average path length} $l = \frac{1}{\lvert V \rvert(\lvert V \rvert - 1)}\sum_{v \neq u}dist(v, u)$.
\end{itemize}

\textit{The density} $\rho$ of a graph is the quotient of $\lvert E \rvert$ and the number of possible edges with the same $\lvert V \rvert$, i.e.\ the number of edges in a complete graph with $\lvert V \rvert$ vertices:
\begin{equation*}
    \rho = \frac{2\lvert E \rvert}{\lvert V \rvert(\lvert V \rvert - 1)}.
\end{equation*}

\paragraph{Main steps.}
Review and describe the main steps when working with the Gephi tool:
\begin{enumerate}
    \item Select the file with the graph in the start window (Figure~\ref{ris:start}).
        \begin{figure}[H]
        \center
        \includegraphics[width=\textwidth]{img/start.png}
        \caption{Start window of the Gephi}
        \label{ris:start}
        \end{figure}
    \item Configuring data import (Figure~\ref{ris:import_settings}).
        \begin{figure}[H]
            \centering
            \begin{subfigure}{.49\textwidth}
                \centering
                \includegraphics[width=\textwidth]{img/csv_options.png}
                \caption{General CSV options}
            \end{subfigure}
            \begin{subfigure}{.49\textwidth}
                \centering
                \includegraphics[width=\textwidth]{img/import.png}
                \caption{Import settings}
            \end{subfigure}
            \caption{Spreadsheet (CSV)}
            \label{ris:import_settings}
        \end{figure}
    \item Choosing different graph layouts (Figure~\ref{ris:layouts}).
        \begin{figure}[H]
            \centering
            \begin{subfigure}{\textwidth}
                \centering
                \includegraphics[width=\textwidth]{img/layout_forceatlas_2.png}
                \caption{ForceAtlas 2 layout}
            \end{subfigure}
            \begin{subfigure}{\textwidth}
                \centering
                \includegraphics[width=\textwidth]{img/layout_yifanhu.png}
                \caption{Yifan Hu layout}
            \end{subfigure}
            \caption{Example of how Gephi works for the network}
            \label{ris:layouts}
        \end{figure}
\end{enumerate}

\subsection{Results}\label{subsec:results}

\textbf{Network overview:}
\begin{enumerate}
    \item \textit{Average Degree} - 8.988.
    \item \textit{Avg.\ Weighted Degree} - 13.338.
    \item \textit{Network Diameter} - 8.
    \item \textit{Graph Density} - 0.002 (sparse graph).
    \item \textit{HITS} is metric determines two values for a page (Figure~\ref{ris:hits}): its authority, which estimates the value of the content of the page, and its hub value, which estimates the value of its links to other pages.
        \begin{figure}[H]
            \centering
            \begin{subfigure}{0.49\textwidth}
                \centering
                \includegraphics[width=\textwidth]{img/hits_hubs.png}
                \caption{Hubs distribution}
            \end{subfigure}
            \begin{subfigure}{0.49\textwidth}
                \centering
                \includegraphics[width=\textwidth]{img/hits_authority.png}
                \caption{Authority distribution}
            \end{subfigure}
            \caption{HITS Metric Report}
            \label{ris:hits}
        \end{figure}
    \item \textit{Modularity} is the strength of division of a network into modules - 0.268.
    \item \textit{PageRank} is used to measure importance of a node, calculating number of incoming edges of the said node (Figure~\ref{ris:pagerank}).
        \begin{figure}[H]
        \center
        \includegraphics[width=\textwidth]{img/pagerank.png}
        \caption{PageRank distribution}
        \label{ris:pagerank}
        \end{figure}
    \item \textit{Connected Components} - 1.
\end{enumerate}

\textbf{Node overview:}
\begin{enumerate}
    \item \textit{Avg.\ Clustering Coefficient} - 0.267.
    \item \textit{Eigenvector Centrality} is used to measure the level of influence of a node within a network (Figure~\ref{ris:eigenvector}).
        \begin{figure}[H]
        \center
        \includegraphics[width=\textwidth]{img/eigenvector.png}
        \caption{Eigenvector centrality distribution}
        \label{ris:eigenvector}
        \end{figure}
\end{enumerate}

\textbf{Edge overview:}
\begin{enumerate}
    \item \textit{Avg.\ Path Length} - 3.003.
\end{enumerate}

\subsection{Conclusion}\label{subsec:conclusion}

This task uses the Gephi network analysis tool.
The main characteristics of the network are analyzed.

\subsection{Appendix}\label{subsec:appendix}

Source dataset: \url{https://snap.stanford.edu/data/soc-sign-bitcoin-alpha.html}.