added tex file

This commit is contained in:
Morten Hjorth-Jensen
2025-09-02 06:31:18 +02:00
parent be1e16849e
commit f6b1134d5f
2 changed files with 907 additions and 0 deletions
Binary file not shown.
+907
View File
@@ -0,0 +1,907 @@
\documentclass[11pt]{article}
\usepackage[breakable]{tcolorbox}
\usepackage{parskip} % Stop auto-indenting (to mimic markdown behaviour)
% Basic figure setup, for now with no caption control since it's done
% automatically by Pandoc (which extracts ![](path) syntax from Markdown).
\usepackage{graphicx}
% Keep aspect ratio if custom image width or height is specified
\setkeys{Gin}{keepaspectratio}
% Maintain compatibility with old templates. Remove in nbconvert 6.0
\let\Oldincludegraphics\includegraphics
% Ensure that by default, figures have no caption (until we provide a
% proper Figure object with a Caption API and a way to capture that
% in the conversion process - todo).
\usepackage{caption}
\DeclareCaptionFormat{nocaption}{}
\captionsetup{format=nocaption,aboveskip=0pt,belowskip=0pt}
\usepackage{float}
\floatplacement{figure}{H} % forces figures to be placed at the correct location
\usepackage{xcolor} % Allow colors to be defined
\usepackage{enumerate} % Needed for markdown enumerations to work
\usepackage{geometry} % Used to adjust the document margins
\usepackage{amsmath} % Equations
\usepackage{amssymb} % Equations
\usepackage{textcomp} % defines textquotesingle
% Hack from http://tex.stackexchange.com/a/47451/13684:
\AtBeginDocument{%
\def\PYZsq{\textquotesingle}% Upright quotes in Pygmentized code
}
\usepackage{upquote} % Upright quotes for verbatim code
\usepackage{eurosym} % defines \euro
\usepackage{iftex}
\ifPDFTeX
\usepackage[T1]{fontenc}
\IfFileExists{alphabeta.sty}{
\usepackage{alphabeta}
}{
\usepackage[mathletters]{ucs}
\usepackage[utf8x]{inputenc}
}
\else
\usepackage{fontspec}
\usepackage{unicode-math}
\fi
\usepackage{fancyvrb} % verbatim replacement that allows latex
\usepackage{grffile} % extends the file name processing of package graphics
% to support a larger range
\makeatletter % fix for old versions of grffile with XeLaTeX
\@ifpackagelater{grffile}{2019/11/01}
{
% Do nothing on new versions
}
{
\def\Gread@@xetex#1{%
\IfFileExists{"\Gin@base".bb}%
{\Gread@eps{\Gin@base.bb}}%
{\Gread@@xetex@aux#1}%
}
}
\makeatother
\usepackage[Export]{adjustbox} % Used to constrain images to a maximum size
\adjustboxset{max size={0.9\linewidth}{0.9\paperheight}}
% The hyperref package gives us a pdf with properly built
% internal navigation ('pdf bookmarks' for the table of contents,
% internal cross-reference links, web links for URLs, etc.)
\usepackage{hyperref}
% The default LaTeX title has an obnoxious amount of whitespace. By default,
% titling removes some of it. It also provides customization options.
\usepackage{titling}
\usepackage{longtable} % longtable support required by pandoc >1.10
\usepackage{booktabs} % table support for pandoc > 1.12.2
\usepackage{array} % table support for pandoc >= 2.11.3
\usepackage{calc} % table minipage width calculation for pandoc >= 2.11.1
\usepackage[inline]{enumitem} % IRkernel/repr support (it uses the enumerate* environment)
\usepackage[normalem]{ulem} % ulem is needed to support strikethroughs (\sout)
% normalem makes italics be italics, not underlines
\usepackage{soul} % strikethrough (\st) support for pandoc >= 3.0.0
\usepackage{mathrsfs}
% Colors for the hyperref package
\definecolor{urlcolor}{rgb}{0,.145,.698}
\definecolor{linkcolor}{rgb}{.71,0.21,0.01}
\definecolor{citecolor}{rgb}{.12,.54,.11}
% ANSI colors
\definecolor{ansi-black}{HTML}{3E424D}
\definecolor{ansi-black-intense}{HTML}{282C36}
\definecolor{ansi-red}{HTML}{E75C58}
\definecolor{ansi-red-intense}{HTML}{B22B31}
\definecolor{ansi-green}{HTML}{00A250}
\definecolor{ansi-green-intense}{HTML}{007427}
\definecolor{ansi-yellow}{HTML}{DDB62B}
\definecolor{ansi-yellow-intense}{HTML}{B27D12}
\definecolor{ansi-blue}{HTML}{208FFB}
\definecolor{ansi-blue-intense}{HTML}{0065CA}
\definecolor{ansi-magenta}{HTML}{D160C4}
\definecolor{ansi-magenta-intense}{HTML}{A03196}
\definecolor{ansi-cyan}{HTML}{60C6C8}
\definecolor{ansi-cyan-intense}{HTML}{258F8F}
\definecolor{ansi-white}{HTML}{C5C1B4}
\definecolor{ansi-white-intense}{HTML}{A1A6B2}
\definecolor{ansi-default-inverse-fg}{HTML}{FFFFFF}
\definecolor{ansi-default-inverse-bg}{HTML}{000000}
% common color for the border for error outputs.
\definecolor{outerrorbackground}{HTML}{FFDFDF}
% commands and environments needed by pandoc snippets
% extracted from the output of `pandoc -s`
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
% Add ',fontsize=\small' for more characters per line
\newenvironment{Shaded}{}{}
\newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{{#1}}}}
\newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.56,0.13,0.00}{{#1}}}
\newcommand{\DecValTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
\newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
\newcommand{\FloatTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
\newcommand{\CharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
\newcommand{\StringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
\newcommand{\CommentTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textit{{#1}}}}
\newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{{#1}}}
\newcommand{\AlertTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}}
\newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.02,0.16,0.49}{{#1}}}
\newcommand{\RegionMarkerTok}[1]{{#1}}
\newcommand{\ErrorTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}}
\newcommand{\NormalTok}[1]{{#1}}
% Additional commands for more recent versions of Pandoc
\newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.53,0.00,0.00}{{#1}}}
\newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
\newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
\newcommand{\SpecialStringTok}[1]{\textcolor[rgb]{0.73,0.40,0.53}{{#1}}}
\newcommand{\ImportTok}[1]{{#1}}
\newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.73,0.13,0.13}{\textit{{#1}}}}
\newcommand{\AnnotationTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
\newcommand{\CommentVarTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
\newcommand{\VariableTok}[1]{\textcolor[rgb]{0.10,0.09,0.49}{{#1}}}
\newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{{#1}}}}
\newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.40,0.40,0.40}{{#1}}}
\newcommand{\BuiltInTok}[1]{{#1}}
\newcommand{\ExtensionTok}[1]{{#1}}
\newcommand{\PreprocessorTok}[1]{\textcolor[rgb]{0.74,0.48,0.00}{{#1}}}
\newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.49,0.56,0.16}{{#1}}}
\newcommand{\InformationTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
\newcommand{\WarningTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
\makeatletter
\newsavebox\pandoc@box
\newcommand*\pandocbounded[1]{%
\sbox\pandoc@box{#1}%
% scaling factors for width and height
\Gscale@div\@tempa\textheight{\dimexpr\ht\pandoc@box+\dp\pandoc@box\relax}%
\Gscale@div\@tempb\linewidth{\wd\pandoc@box}%
% select the smaller of both
\ifdim\@tempb\p@<\@tempa\p@
\let\@tempa\@tempb
\fi
% scaling accordingly (\@tempa < 1)
\ifdim\@tempa\p@<\p@
\scalebox{\@tempa}{\usebox\pandoc@box}%
% scaling not needed, use as it is
\else
\usebox{\pandoc@box}%
\fi
}
\makeatother
% Define a nice break command that doesn't care if a line doesn't already
% exist.
\def\br{\hspace*{\fill} \\* }
% Math Jax compatibility definitions
\def\gt{>}
\def\lt{<}
\let\Oldtex\TeX
\let\Oldlatex\LaTeX
\renewcommand{\TeX}{\textrm{\Oldtex}}
\renewcommand{\LaTeX}{\textrm{\Oldlatex}}
% Document parameters
% Document title
\title{Project1}
% Pygments definitions
\makeatletter
\def\PY@reset{\let\PY@it=\relax \let\PY@bf=\relax%
\let\PY@ul=\relax \let\PY@tc=\relax%
\let\PY@bc=\relax \let\PY@ff=\relax}
\def\PY@tok#1{\csname PY@tok@#1\endcsname}
\def\PY@toks#1+{\ifx\relax#1\empty\else%
\PY@tok{#1}\expandafter\PY@toks\fi}
\def\PY@do#1{\PY@bc{\PY@tc{\PY@ul{%
\PY@it{\PY@bf{\PY@ff{#1}}}}}}}
\def\PY#1#2{\PY@reset\PY@toks#1+\relax+\PY@do{#2}}
\@namedef{PY@tok@w}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.73,0.73}{##1}}}
\@namedef{PY@tok@c}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.24,0.48,0.48}{##1}}}
\@namedef{PY@tok@cp}{\def\PY@tc##1{\textcolor[rgb]{0.61,0.40,0.00}{##1}}}
\@namedef{PY@tok@k}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@kp}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@kt}{\def\PY@tc##1{\textcolor[rgb]{0.69,0.00,0.25}{##1}}}
\@namedef{PY@tok@o}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@ow}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.67,0.13,1.00}{##1}}}
\@namedef{PY@tok@nb}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@nf}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}}
\@namedef{PY@tok@nc}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}}
\@namedef{PY@tok@nn}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}}
\@namedef{PY@tok@ne}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.80,0.25,0.22}{##1}}}
\@namedef{PY@tok@nv}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\@namedef{PY@tok@no}{\def\PY@tc##1{\textcolor[rgb]{0.53,0.00,0.00}{##1}}}
\@namedef{PY@tok@nl}{\def\PY@tc##1{\textcolor[rgb]{0.46,0.46,0.00}{##1}}}
\@namedef{PY@tok@ni}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.44,0.44,0.44}{##1}}}
\@namedef{PY@tok@na}{\def\PY@tc##1{\textcolor[rgb]{0.41,0.47,0.13}{##1}}}
\@namedef{PY@tok@nt}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@nd}{\def\PY@tc##1{\textcolor[rgb]{0.67,0.13,1.00}{##1}}}
\@namedef{PY@tok@s}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@sd}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@si}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.64,0.35,0.47}{##1}}}
\@namedef{PY@tok@se}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.67,0.36,0.12}{##1}}}
\@namedef{PY@tok@sr}{\def\PY@tc##1{\textcolor[rgb]{0.64,0.35,0.47}{##1}}}
\@namedef{PY@tok@ss}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\@namedef{PY@tok@sx}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@m}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@gh}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,0.50}{##1}}}
\@namedef{PY@tok@gu}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.50,0.00,0.50}{##1}}}
\@namedef{PY@tok@gd}{\def\PY@tc##1{\textcolor[rgb]{0.63,0.00,0.00}{##1}}}
\@namedef{PY@tok@gi}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.52,0.00}{##1}}}
\@namedef{PY@tok@gr}{\def\PY@tc##1{\textcolor[rgb]{0.89,0.00,0.00}{##1}}}
\@namedef{PY@tok@ge}{\let\PY@it=\textit}
\@namedef{PY@tok@gs}{\let\PY@bf=\textbf}
\@namedef{PY@tok@ges}{\let\PY@bf=\textbf\let\PY@it=\textit}
\@namedef{PY@tok@gp}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,0.50}{##1}}}
\@namedef{PY@tok@go}{\def\PY@tc##1{\textcolor[rgb]{0.44,0.44,0.44}{##1}}}
\@namedef{PY@tok@gt}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.27,0.87}{##1}}}
\@namedef{PY@tok@err}{\def\PY@bc##1{{\setlength{\fboxsep}{\string -\fboxrule}\fcolorbox[rgb]{1.00,0.00,0.00}{1,1,1}{\strut ##1}}}}
\@namedef{PY@tok@kc}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@kd}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@kn}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@kr}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@bp}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@fm}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}}
\@namedef{PY@tok@vc}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\@namedef{PY@tok@vg}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\@namedef{PY@tok@vi}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\@namedef{PY@tok@vm}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\@namedef{PY@tok@sa}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@sb}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@sc}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@dl}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@s2}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@sh}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@s1}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@mb}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@mf}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@mh}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@mi}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@il}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@mo}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@ch}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.24,0.48,0.48}{##1}}}
\@namedef{PY@tok@cm}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.24,0.48,0.48}{##1}}}
\@namedef{PY@tok@cpf}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.24,0.48,0.48}{##1}}}
\@namedef{PY@tok@c1}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.24,0.48,0.48}{##1}}}
\@namedef{PY@tok@cs}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.24,0.48,0.48}{##1}}}
\def\PYZbs{\char`\\}
\def\PYZus{\char`\_}
\def\PYZob{\char`\{}
\def\PYZcb{\char`\}}
\def\PYZca{\char`\^}
\def\PYZam{\char`\&}
\def\PYZlt{\char`\<}
\def\PYZgt{\char`\>}
\def\PYZsh{\char`\#}
\def\PYZpc{\char`\%}
\def\PYZdl{\char`\$}
\def\PYZhy{\char`\-}
\def\PYZsq{\char`\'}
\def\PYZdq{\char`\"}
\def\PYZti{\char`\~}
% for compatibility with earlier versions
\def\PYZat{@}
\def\PYZlb{[}
\def\PYZrb{]}
\makeatother
% For linebreaks inside Verbatim environment from package fancyvrb.
\makeatletter
\newbox\Wrappedcontinuationbox
\newbox\Wrappedvisiblespacebox
\newcommand*\Wrappedvisiblespace {\textcolor{red}{\textvisiblespace}}
\newcommand*\Wrappedcontinuationsymbol {\textcolor{red}{\llap{\tiny$\m@th\hookrightarrow$}}}
\newcommand*\Wrappedcontinuationindent {3ex }
\newcommand*\Wrappedafterbreak {\kern\Wrappedcontinuationindent\copy\Wrappedcontinuationbox}
% Take advantage of the already applied Pygments mark-up to insert
% potential linebreaks for TeX processing.
% {, <, #, %, $, ' and ": go to next line.
% _, }, ^, &, >, - and ~: stay at end of broken line.
% Use of \textquotesingle for straight quote.
\newcommand*\Wrappedbreaksatspecials {%
\def\PYGZus{\discretionary{\char`\_}{\Wrappedafterbreak}{\char`\_}}%
\def\PYGZob{\discretionary{}{\Wrappedafterbreak\char`\{}{\char`\{}}%
\def\PYGZcb{\discretionary{\char`\}}{\Wrappedafterbreak}{\char`\}}}%
\def\PYGZca{\discretionary{\char`\^}{\Wrappedafterbreak}{\char`\^}}%
\def\PYGZam{\discretionary{\char`\&}{\Wrappedafterbreak}{\char`\&}}%
\def\PYGZlt{\discretionary{}{\Wrappedafterbreak\char`\<}{\char`\<}}%
\def\PYGZgt{\discretionary{\char`\>}{\Wrappedafterbreak}{\char`\>}}%
\def\PYGZsh{\discretionary{}{\Wrappedafterbreak\char`\#}{\char`\#}}%
\def\PYGZpc{\discretionary{}{\Wrappedafterbreak\char`\%}{\char`\%}}%
\def\PYGZdl{\discretionary{}{\Wrappedafterbreak\char`\$}{\char`\$}}%
\def\PYGZhy{\discretionary{\char`\-}{\Wrappedafterbreak}{\char`\-}}%
\def\PYGZsq{\discretionary{}{\Wrappedafterbreak\textquotesingle}{\textquotesingle}}%
\def\PYGZdq{\discretionary{}{\Wrappedafterbreak\char`\"}{\char`\"}}%
\def\PYGZti{\discretionary{\char`\~}{\Wrappedafterbreak}{\char`\~}}%
}
% Some characters . , ; ? ! / are not pygmentized.
% This macro makes them "active" and they will insert potential linebreaks
\newcommand*\Wrappedbreaksatpunct {%
\lccode`\~`\.\lowercase{\def~}{\discretionary{\hbox{\char`\.}}{\Wrappedafterbreak}{\hbox{\char`\.}}}%
\lccode`\~`\,\lowercase{\def~}{\discretionary{\hbox{\char`\,}}{\Wrappedafterbreak}{\hbox{\char`\,}}}%
\lccode`\~`\;\lowercase{\def~}{\discretionary{\hbox{\char`\;}}{\Wrappedafterbreak}{\hbox{\char`\;}}}%
\lccode`\~`\:\lowercase{\def~}{\discretionary{\hbox{\char`\:}}{\Wrappedafterbreak}{\hbox{\char`\:}}}%
\lccode`\~`\?\lowercase{\def~}{\discretionary{\hbox{\char`\?}}{\Wrappedafterbreak}{\hbox{\char`\?}}}%
\lccode`\~`\!\lowercase{\def~}{\discretionary{\hbox{\char`\!}}{\Wrappedafterbreak}{\hbox{\char`\!}}}%
\lccode`\~`\/\lowercase{\def~}{\discretionary{\hbox{\char`\/}}{\Wrappedafterbreak}{\hbox{\char`\/}}}%
\catcode`\.\active
\catcode`\,\active
\catcode`\;\active
\catcode`\:\active
\catcode`\?\active
\catcode`\!\active
\catcode`\/\active
\lccode`\~`\~
}
\makeatother
\let\OriginalVerbatim=\Verbatim
\makeatletter
\renewcommand{\Verbatim}[1][1]{%
%\parskip\z@skip
\sbox\Wrappedcontinuationbox {\Wrappedcontinuationsymbol}%
\sbox\Wrappedvisiblespacebox {\FV@SetupFont\Wrappedvisiblespace}%
\def\FancyVerbFormatLine ##1{\hsize\linewidth
\vtop{\raggedright\hyphenpenalty\z@\exhyphenpenalty\z@
\doublehyphendemerits\z@\finalhyphendemerits\z@
\strut ##1\strut}%
}%
% If the linebreak is at a space, the latter will be displayed as visible
% space at end of first line, and a continuation symbol starts next line.
% Stretch/shrink are however usually zero for typewriter font.
\def\FV@Space {%
\nobreak\hskip\z@ plus\fontdimen3\font minus\fontdimen4\font
\discretionary{\copy\Wrappedvisiblespacebox}{\Wrappedafterbreak}
{\kern\fontdimen2\font}%
}%
% Allow breaks at special characters using \PYG... macros.
\Wrappedbreaksatspecials
% Breaks at punctuation characters . , ; ? ! and / need catcode=\active
\OriginalVerbatim[#1,codes*=\Wrappedbreaksatpunct]%
}
\makeatother
% Exact colors from NB
\definecolor{incolor}{HTML}{303F9F}
\definecolor{outcolor}{HTML}{D84315}
\definecolor{cellborder}{HTML}{CFCFCF}
\definecolor{cellbackground}{HTML}{F7F7F7}
% prompt
\makeatletter
\newcommand{\boxspacing}{\kern\kvtcb@left@rule\kern\kvtcb@boxsep}
\makeatother
\newcommand{\prompt}[4]{
{\ttfamily\llap{{\color{#2}[#3]:\hspace{3pt}#4}}\vspace{-\baselineskip}}
}
% Prevent overflowing lines due to hard-to-break entities
\sloppy
% Setup hyperref package
\hypersetup{
breaklinks=true, % so long urls are correctly broken across lines
colorlinks=true,
urlcolor=urlcolor,
linkcolor=linkcolor,
citecolor=citecolor,
}
% Slightly bigger margins than the latex defaults
\geometry{verbose,tmargin=1in,bmargin=1in,lmargin=1in,rmargin=1in}
\begin{document}
\maketitle
\hypertarget{project-1-on-machine-learning-deadline-october-6-midnight-2025}{%
\section*{Project 1 on Machine Learning, deadline October 6 (midnight),
2025}\label{project-1-on-machine-learning-deadline-october-6-midnight-2025}}
\textbf{Data Analysis and Machine Learning FYS-STK3155/FYS4155},
University of Oslo, Norway
Date: \textbf{September 2}
\hypertarget{preamble-note-on-writing-reports-using-reference-material-ai-and-other-tools}{%
\subsection*{Preamble: Note on writing reports, using reference material,
AI and other
tools}\label{preamble-note-on-writing-reports-using-reference-material-ai-and-other-tools}}
We want you to answer the three different projects by handing in reports
written like a standard scientific/technical report. The links at
\url{https://github.com/CompPhysics/MachineLearning/tree/master/doc/Projects}
contain more information. There you can find examples of previous
reports, the projects themselves, how we rade reports etc. How to write
reports will also be discussed during the various lab sessions. Please
do ask us if you are in doubt.
When using codes and material from other sources, you should refer to
these in the bibliography of your report, indicating wherefrom you for
example got the code, whether this is from the lecture notes, softwares
like Scikit-Learn, TensorFlow, PyTorch or other sources. These sources
should always be cited correctly. How to cite some of the libraries is
often indicated from their corresponding GitHub sites or websites, see
for example how to cite Scikit-Learn at
\url{https://scikit-learn.org/dev/about.html}.
We enocurage you to use tools like
\href{https://openai.com/chatgpt/}{ChatGPT} or similar in writing the
report. If you use for example ChatGPT, please do cite it properly and
include (if possible) your questions and answers as an addition to the
report. This can be uploaded to for example your website, GitHub/GitLab
or similar as supplemental material.
If you would like to study other data sets, feel free to propose other
sets. What we have proposed here are mere suggestions from our side. If
you opt for another data set, consider using a set which has been
studied in the scientific literature. This makes it easier for you to
compare and analyze your results. Comparing with existing results from
the scientific literature is also an essential element of the scientific
discussion. The University of California at Irvine with its Machine
Learning repository at \url{https://archive.ics.uci.edu/ml/index.php} is
an excellent site to look up for examples and inspiration.
\href{https://www.kaggle.com/}{Kaggle.com} is an equally interesting
site. Feel free to explore these sites. When selecting other data sets,
make sure these are sets used for regression problems (not
classification).
\hypertarget{regression-analysis-and-resampling-methods}{%
\subsection*{Regression analysis and resampling
methods}\label{regression-analysis-and-resampling-methods}}
The main aim of this project is to study in more detail various
regression methods, including Ordinary Least Squares (OLS) reegression,
Ridge regression and LASSO regression. In addition to the scientific
part, in this course we want also to give you an experience in writing
scientific reports.
We will study how to fit polynomials to specific one-dimensional
functions (feel free to replace the suggested function with more
complicated ones).
We will use Runge's function (see
\url{https://en.wikipedia.org/wiki/Runge\%27s_phenomenon} for a
discussion). The one-dimensional function we will study is
\[
f(x) = \frac{1}{1+25x^2}.
\]
Our first step will be to perform an OLS regression analysis of this
function, trying out a polynomial fit with an \(x\) dependence of the
form \([x,x^2,\dots]\). You can use a uniform distribution to set up the
arrays of values for \(x \in [-1,1]\), or alternatively use a fixed step
size. Thereafter we will repeat many of the same steps when using the
Ridge and Lasso regression methods, introducing thereby a dependence on
the hyperparameter (penalty) \(\lambda\).
We will also include bootstrap as a resampling technique in order to
study the so-called \textbf{bias-variance tradeoff}. After that we will
include the so-called cross-validation technique.
\hypertarget{part-a-ordinary-least-square-ols-for-the-runge-function}{%
\subsubsection*{Part a : Ordinary Least Square (OLS) for the Runge
function}\label{part-a-ordinary-least-square-ols-for-the-runge-function}}
We will generate our own dataset for abovementioned function
\(\mathrm{Runge}(x)\) function with \(x\in [-1,1]\). You should explore
also the addition of an added stochastic noise to this function using
the normal distribution \(N(0,1)\).
\emph{Write your own code} (using for example the pseudoinverse function
\textbf{pinv} from \textbf{Numpy} ) and perform a standard
\textbf{ordinary least square regression} analysis using polynomials in
\(x\) up to order \(15\) or higher. Explore the dependence on the number
of data points and the polynomial degree.
Evaluate the mean Squared error (MSE)
\[
MSE(\boldsymbol{y},\tilde{\boldsymbol{y}}) = \frac{1}{n}
\sum_{i=0}^{n-1}(y_i-\tilde{y}_i)^2,
\]
and the \(R^2\) score function. If \(\tilde{\boldsymbol{y}}_i\) is the
predicted value of the \(i-th\) sample and \(y_i\) is the corresponding
true value, then the score \(R^2\) is defined as
\[
R^2(\boldsymbol{y}, \tilde{\boldsymbol{y}}) = 1 - \frac{\sum_{i=0}^{n - 1} (y_i - \tilde{y}_i)^2}{\sum_{i=0}^{n - 1} (y_i - \bar{y})^2},
\]
where we have defined the mean value of \(\boldsymbol{y}\) as
\[
\bar{y} = \frac{1}{n} \sum_{i=0}^{n - 1} y_i.
\]
Plot the resulting scores (MSE and R\(^2\)) as functions of the
polynomial degree (here up to polymial degree 15). Plot also the
parameters \(\theta\) as you increase the order of the polynomial.
Comment your results.
Your code has to include a scaling/centering of the data (for example by
subtracting the mean value), and a split of the data in training and
test data. For the scaling you can either write your own code or use for
example the function for splitting training data provided by the library
\textbf{Scikit-Learn} (make sure you have installed it). This function
is called \(train\_test\_split\). \textbf{You should present a critical
discussion of why and how you have scaled or not scaled the data}.
It is normal in essentially all Machine Learning studies to split the
data in a training set and a test set (eventually also an additional
validation set). There is no explicit recipe for how much data should be
included as training data and say test data. An accepted rule of thumb
is to use approximately \(2/3\) to \(4/5\) of the data as training data.
You can easily reuse the solutions to your exercises from week 35. See
also the lecture slides from week 35 and week 36.
On scaling, we recommend reading the following section from the
scikit-learn software description, see
\url{https://scikit-learn.org/stable/auto_examples/preprocessing/plot_all_scaling.html\#plot-all-scaling-standard-scaler-section}.
\hypertarget{part-b-adding-ridge-regression-for-the-runge-function}{%
\subsubsection*{Part b: Adding Ridge regression for the Runge
function}\label{part-b-adding-ridge-regression-for-the-runge-function}}
Write your own code for the Ridge method as done in the previous
exercise. The lecture notes from week 35 and 36 contain more
information. Furthermore, the results from the exercise set from week 36
is something you can reuse here.
Perform the same analysis as you did in the previous exercise but now
for different values of \(\lambda\). Compare and analyze your results
with those obtained in part a) with the OLS method. Study the dependence
on \(\lambda\).
\hypertarget{part-c-writing-your-own-gradient-descent-code}{%
\subsubsection*{Part c: Writing your own gradient descent
code}\label{part-c-writing-your-own-gradient-descent-code}}
Replace now the analytical expressions for the optimal parameters
\(\boldsymbol{\theta}\) with your own gradient descent code. In this
exercise we focus only on the simplest gradient descent approach with a
fixed learning rate (see the exercises from week 37 and the lecture
notes from week 36).
Study and compare your results from parts a) and b) with your gradient
descent approch. Discuss in particular the role of the learning rate.
\hypertarget{part-d-including-momentum-and-more-advanced-ways-to-update-the-learning-the-rate}{%
\subsubsection*{Part d: Including momentum and more advanced ways to
update the learning the
rate}\label{part-d-including-momentum-and-more-advanced-ways-to-update-the-learning-the-rate}}
We keep our focus on OLS and Ridge regression and update our code for
the gradient descent method by including \textbf{momentum},
\textbf{ADAgrad}, \textbf{RMSprop} and \textbf{ADAM} as methods fro
iteratively updating your learning rate. Discuss the results and compare
the different methods applied to the one-dimensional Runge function. The
lecture notes from week 37 contain several examples on how to implement
these methods.
\hypertarget{part-e-writing-our-own-code-for-lasso-regression}{%
\subsubsection*{Part e: Writing our own code for Lasso
regression}\label{part-e-writing-our-own-code-for-lasso-regression}}
LASSO regression (see lecture slides from week 36 and week 37)
represents our first encounter with a machine learning method which
cannot be solved through analytical expressions (as in OLS and Ridge
regression). Use the gradient descent methods you developed in parts c)
and d) to solve the LASSO optimization problem. You can compare your
results with the functionalities of \textbf{Scikit-Learn}.
Discuss (critically) your results for the Runge function from OLS, Ridge
and LASSO regression using the various gradient descent approaches.
\hypertarget{part-f-stochastic-gradient-descent}{%
\subsubsection*{Part f: Stochastic gradient
descent}\label{part-f-stochastic-gradient-descent}}
Our last gradient step is to include stochastic gradient descent using
the same methods to update the learning rates as in parts c-e). Compare
and discuss your results with and without stochastic gradient and give a
critical assessment of the various methods.
\hypertarget{part-g-bias-variance-trade-off-and-resampling-techniques}{%
\subsubsection*{Part g: Bias-variance trade-off and resampling
techniques}\label{part-g-bias-variance-trade-off-and-resampling-techniques}}
Our aim here is to study the bias-variance trade-off by implementing the
\textbf{bootstrap} resampling technique. \textbf{We will only use the
simpler ordinary least squares here}.
With a code which does OLS and includes resampling techniques, we will
now discuss the bias-variance trade-off in the context of continuous
predictions such as regression. However, many of the intuitions and
ideas discussed here also carry over to classification tasks and
basically all Machine Learning algorithms.
Before you perform an analysis of the bias-variance trade-off on your
test data, make first a figure similar to Fig. 2.11 of Hastie,
Tibshirani, and Friedman. Figure 2.11 of this reference displays only
the test and training MSEs. The test MSE can be used to indicate
possible regions of low/high bias and variance. You will most likely not
get an equally smooth curve! You may also need to increase the
polynomial order and play around with the number of data points as well
(see also the exercise set from week 35).
With this result we move on to the bias-variance trade-off analysis.
Consider a dataset \(\mathcal{L}\) consisting of the data
\(\mathbf{X}_\mathcal{L}=\{(y_j, \boldsymbol{x}_j), j=0\ldots n-1\}\).
We assume that the true data is generated from a noisy model
\[
\boldsymbol{y}=f(\boldsymbol{x}) + \boldsymbol{\epsilon}.
\]
Here \(\epsilon\) is normally distributed with mean zero and standard
deviation \(\sigma^2\).
In our derivation of the ordinary least squares method we defined then
an approximation to the function \(f\) in terms of the parameters
\(\boldsymbol{\theta}\) and the design matrix \(\boldsymbol{X}\) which
embody our model, that is
\(\boldsymbol{\tilde{y}}=\boldsymbol{X}\boldsymbol{\theta}\).
The parameters \(\boldsymbol{\theta}\) are in turn found by optimizing
the mean squared error via the so-called cost function
\[
C(\boldsymbol{X},\boldsymbol{\theta}) =\frac{1}{n}\sum_{i=0}^{n-1}(y_i-\tilde{y}_i)^2=\mathbb{E}\left[(\boldsymbol{y}-\boldsymbol{\tilde{y}})^2\right].
\]
Here the expected value \(\mathbb{E}\) is the sample value.
Show that you can rewrite this in terms of a term which contains the
variance of the model itself (the so-called variance term), a term which
measures the deviation from the true data and the mean value of the
model (the bias term) and finally the variance of the noise.
That is, show that
\[
\mathbb{E}\left[(\boldsymbol{y}-\boldsymbol{\tilde{y}})^2\right]=\mathrm{Bias}[\tilde{y}]+\mathrm{var}[\tilde{y}]+\sigma^2,
\]
with (we approximate \(f(\boldsymbol{x})\approx \boldsymbol{y}\))
\[
\mathrm{Bias}[\tilde{y}]=\mathbb{E}\left[\left(\boldsymbol{y}-\mathbb{E}\left[\boldsymbol{\tilde{y}}\right]\right)^2\right],
\]
and
\[
\mathrm{var}[\tilde{y}]=\mathbb{E}\left[\left(\tilde{\boldsymbol{y}}-\mathbb{E}\left[\boldsymbol{\tilde{y}}\right]\right)^2\right]=\frac{1}{n}\sum_i(\tilde{y}_i-\mathbb{E}\left[\boldsymbol{\tilde{y}}\right])^2.
\]
\textbf{Important note}: Since the function \(f(x)\) is unknown, in
order to be able to evalute the bias, we replace \(f(\boldsymbol{x})\)
in the expression for the bias with \(\boldsymbol{y}\).
The answer to this exercise should be included in the theory part of the
report. This exercise is also part of the weekly exercises of week 38.
Explain what the terms mean and discuss their interpretations.
Perform then a bias-variance analysis of the Runge function by studying
the MSE value as function of the complexity of your model.
Discuss the bias and variance trade-off as function of your model
complexity (the degree of the polynomial) and the number of data points,
and possibly also your training and test data using the
\textbf{bootstrap} resampling method. You can follow the code example in
the jupyter-book at
\url{https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/chapter3.html\#the-bias-variance-tradeoff}.
\hypertarget{part-h-cross-validation-as-resampling-techniques-adding-more-complexity}{%
\subsubsection*{Part h): Cross-validation as resampling techniques,
adding more
complexity}\label{part-h-cross-validation-as-resampling-techniques-adding-more-complexity}}
The aim here is to implement another widely popular resampling
technique, the so-called cross-validation method.
Implement the \(k\)-fold cross-validation algorithm (feel free to use
the functionality of \textbf{Scikit-Learn} or write your own code) and
evaluate again the MSE function resulting from the test folds.
Compare the MSE you get from your cross-validation code with the one you
got from your \textbf{bootstrap} code from the previous exercise.
Comment and interpret your results.
In addition to using the ordinary least squares method, you should
include both Ridge and Lasso regression in the final analysis.
\hypertarget{background-literature}{%
\subsection*{Background literature}\label{background-literature}}
\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\item
For a discussion and derivation of the variances and mean squared
errors using linear regression, see the
\href{https://arxiv.org/abs/1509.09169}{Lecture notes on ridge
regression by Wessel N. van Wieringen}
\item
The textbook of
\href{https://www.springer.com/gp/book/9780387848570}{Trevor Hastie,
Robert Tibshirani, Jerome H. Friedman, The Elements of Statistical
Learning, Springer}, chapters 3 and 7 are the most relevant ones for
the analysis of parts g) and h).
\end{enumerate}
\hypertarget{introduction-to-numerical-projects}{%
\subsection*{Introduction to numerical
projects}\label{introduction-to-numerical-projects}}
Here follows a brief recipe and recommendation on how to answer the
various questions when preparing your answers.
\begin{itemize}
\item
Give a short description of the nature of the problem and the eventual
numerical methods you have used.
\item
Describe the algorithm you have used and/or developed. Here you may
find it convenient to use pseudocoding. In many cases you can describe
the algorithm in the program itself.
\item
Include the source code of your program. Comment your program
properly. You should have the code at your GitHub/GitLab link. You can
also place the code in an appendix of your report.
\item
If possible, try to find analytic solutions, or known limits in order
to test your program when developing the code.
\item
Include your results either in figure form or in a table. Remember to
label your results. All tables and figures should have relevant
captions and labels on the axes.
\item
Try to evaluate the reliabilty and numerical stability/precision of
your results. If possible, include a qualitative and/or quantitative
discussion of the numerical stability, eventual loss of precision etc.
\item
Try to give an interpretation of you results in your answers to the
problems.
\item
Critique: if possible include your comments and reflections about the
exercise, whether you felt you learnt something, ideas for
improvements and other thoughts you've made when solving the exercise.
We wish to keep this course at the interactive level and your comments
can help us improve it.
\item
Try to establish a practice where you log your work at the
computerlab. You may find such a logbook very handy at later stages in
your work, especially when you don't properly remember what a previous
test version of your program did. Here you could also record the time
spent on solving the exercise, various algorithms you may have tested
or other topics which you feel worthy of mentioning.
\end{itemize}
\hypertarget{format-for-electronic-delivery-of-report-and-programs}{%
\subsection*{Format for electronic delivery of report and
programs}\label{format-for-electronic-delivery-of-report-and-programs}}
The preferred format for the report is a PDF file. You can also use DOC
or postscript formats or as an ipython notebook file. As programming
language we prefer that you choose between C/C++, Fortran2008, Julia or
Python. The following prescription should be followed when preparing the
report:
\begin{itemize}
\item
Use Canvas to hand in your projects, log in at
\url{https://www.uio.no/english/services/it/education/canvas/} with
your normal UiO username and password.
\item
Upload \textbf{only} the report file or the link to your GitHub/GitLab
or similar typo of repos! For the source code file(s) you have
developed please provide us with your link to your GitHub/GitLab or
similar domain. The report file should include all of your discussions
and a list of the codes you have developed. Do not include library
files which are available at the course homepage, unless you have made
specific changes to them.
\item
In your GitHub/GitLab or similar repository, please include a folder
which contains selected results. These can be in the form of output
from your code for a selected set of runs and input parameters.
\end{itemize}
Finally, we encourage you to collaborate. Optimal working groups consist
of 2-3 students. You can then hand in a common report.
\hypertarget{software-and-needed-installations}{%
\subsection*{Software and needed
installations}\label{software-and-needed-installations}}
If you have Python installed (we recommend Python3) and you feel pretty
familiar with installing different packages, we recommend that you
install the following Python packages via \textbf{pip} as 1. pip install
numpy scipy matplotlib ipython scikit-learn tensorflow sympy pandas
pillow
For Python3, replace \textbf{pip} with \textbf{pip3}.
See below for a discussion of \textbf{tensorflow} and
\textbf{scikit-learn}.
For OSX users we recommend also, after having installed Xcode, to
install \textbf{brew}. Brew allows for a seamless installation of
additional software via for example 1. brew install python3
For Linux users, with its variety of distributions like for example the
widely popular Ubuntu distribution you can use \textbf{pip} as well and
simply install Python as 1. sudo apt-get install python3 (or python for
python2.7)
etc etc.
If you don't want to install various Python packages with their
dependencies separately, we recommend two widely used distrubutions
which set up all relevant dependencies for Python, namely 1.
\href{https://docs.anaconda.com/}{Anaconda} Anaconda is an open source
distribution of the Python and R programming languages for large-scale
data processing, predictive analytics, and scientific computing, that
aims to simplify package management and deployment. Package versions are
managed by the package management system \textbf{conda}
\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\setcounter{enumi}{1}
\tightlist
\item
\href{https://www.enthought.com/product/canopy/}{Enthought canopy} is
a Python distribution for scientific and analytic computing
distribution and analysis environment, available for free and under a
commercial license.
\end{enumerate}
Popular software packages written in Python for ML are
\begin{itemize}
\item
\href{http://scikit-learn.org/stable/}{Scikit-learn},
\item
\href{https://www.tensorflow.org/}{Tensorflow},
\item
\href{http://pytorch.org/}{PyTorch} and
\item
\href{https://keras.io/}{Keras}.
\end{itemize}
These are all freely available at their respective GitHub sites. They
encompass communities of developers in the thousands or more. And the
number of code developers and contributors keeps increasing.
% Add a bibliography block to the postdoc
\end{document}