pushing final oblig

This commit is contained in:
Chris Sanden
2026-04-28 15:30:52 +02:00
parent a4403bb53f
commit 321df5a296
43 changed files with 1540 additions and 7 deletions

7
.gitignore vendored
View File

@@ -2,10 +2,3 @@
.Rhistory
.RData
.Ruserdata
.codex
<<<<<<< Updated upstream
=======
.env
.vscode
.DS_Store
>>>>>>> Stashed changes

36
Oblig/3c/latex/main.tex Normal file
View File

@@ -0,0 +1,36 @@
\documentclass[11pt,a4paper]{article}
\usepackage[norsk]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath, amssymb}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{geometry}
\usepackage{float}
\usepackage{hyperref}
\usepackage[newfloat]{minted}
\geometry{margin=2.5cm}
\setminted{
fontsize=\small,
linenos,
breaklines,
frame=lines
}
\title{Oblig 3c\\Lineær regresjon med usikkerhet}
\author{Navn: \underline{\hspace{6cm}}}
\date{\today}
\begin{document}
\maketitle
\tableofcontents
\newpage
\input{sections/task1_kap17_1c}
\input{sections/task2_kap17_1d}
\input{sections/task3_terningdropp}
\input{sections/task4_utvalgsforsok}
\end{document}

View File

@@ -0,0 +1,18 @@
\section{Innledning}
I denne rapporten ser vi på lineær regresjon med usikkerhet i en Bayesiansk ramme.
Målet er å bruke teorien fra kapittel 17 til å beskrive både selve regresjonslinjen og
usikkerheten rundt den. Det innebærer at vi ikke bare finner ett enkelt uttrykk for en
linje, men også undersøker hvordan usikkerheten i dataene påvirker stigningstall,
standardavvik, posteriorfordelinger og intervallestimater.
Rapporten er delt i to hoveddeler. Først løses to bokoppgaver fra kapittel 17, der vi
bruker de generelle formlene for posterior- og prediktive fordelinger i lineær regresjon.
Deretter brukes de samme ideene på terningdropp-dataene fra oppgavesettet, hvor vi
analyserer sammenhengen mellom dropphøyde og sprettlengde. Til slutt undersøker vi
hvordan regresjonslinjer og intervallestimater varierer når vi bare bruker tilfeldige
delutvalg av observasjonene.
I arbeidet brukes R til å beregne regresjonslinjer, posteriorfordelinger, kredibilitetsintervall
og figurer. Figurene brukes videre for å synliggjøre både mønsteret i dataene og hvordan
usikkerheten endrer seg når datagrunnlaget blir større eller mindre.

View File

@@ -0,0 +1,103 @@
\section{Oppgave 1: Kapittel 17, oppgave 1c}
I denne oppgaven bruker vi observasjonene
\[
\{(2,10), (3,8), (4,8), (6,7)\},
\]
og vi er gitt \(\sigma_0 = 0.5\) og \(n_0 = 4\).
\subsection{Tema}
Temaet er Bayesiansk lineær regresjon med informativ prior for usikkerheten. Vi skal
finne posteriorfordelingen til \(\tau\), posteriorfordelingen til \(y(x)\),
prediktiv fordeling for \(Y_+(x)\), samt tilhørende intervallestimater.
\subsection{Prior og hyperparametre}
Siden \(\sigma_0 = 0.5\) og \(n_0 = 4\), får vi
\[
\nu_0 = n_0 - 2 = 2,
\qquad
SS_0 = \sigma_0^2 \nu_0 = 0.5^2 \cdot 2 = 0.5.
\]
Dette brukes videre sammen med regresjonsstatistikkene fra datasettet.
\subsection{Posterior for \(\tau\)}
Når regresjonslinjen er estimert, får vi posteriorfordelingen
\[
\tau \mid \text{data} \sim \Gamma\!\left(\frac{\nu_1}{2}, \frac{SS_1}{2}\right).
\]
Her settes de konkrete tallene inn fra R-skriptet.
\subsection{Posterior for \(y(x)\)}
For en vilkårlig verdi \(x\) får vi
\[
y(x)\mid \text{data}
\sim
t\!\left(\alpha_0 + \beta x,\;
s_1\sqrt{\frac{1}{n} + \frac{(x-\bar{x})^2}{SS_x}},\;
\nu_1\right).
\]
De konkrete parameterverdiene kan hentes fra skriptet og settes inn her.
\subsection{Prediktiv fordeling for \(Y_+(x)\)}
Den prediktive fordelingen for en ny observasjon er
\[
Y_+(x)\mid \text{data}
\sim
t\!\left(\alpha_0 + \beta x,\;
s_1\sqrt{1 + \frac{1}{n} + \frac{(x-\bar{x})^2}{SS_x}},\;
\nu_1\right).
\]
\subsection{Intervallestimater}
Et \(95\%\)-kredibilitetsintervall for regresjonslinjen er
\[
I_{0.05}(x)
=
\alpha_0 + \beta x
\pm
t_{\nu_1,0.025}\,
s_1\sqrt{\frac{1}{n} + \frac{(x-\bar{x})^2}{SS_x}}.
\]
Et \(95\%\)-prediktivt intervall fås tilsvarende ved å legge til \(1\) inne i roten.
\subsection{Kommentar}
Denne oppgaven er en direkte anvendelse av formlene i kapittel 17. Hovedpoenget er
at vi kombinerer observasjonene med en svak informativ prior for usikkerheten, og
deretter leser av posterior- og prediktive fordelinger fra de oppdaterte hyperparametrene.
\subsection{R-kode}
Listing~\ref{lst:task12-r} viser delen av R-skriptet som løser bokoppgavene 1c og 1d.
\begin{listing}[H]
\begin{minted}{r}
task_1c <- data.frame(
x = c(2, 3, 4, 6),
y = c(10, 8, 8, 7)
)
fit_1c <- fit_simple_regression(task_1c$x, task_1c$y, nu0 = 4 - 2, SS0 = 0.5^2 * (4 - 2))
print_regression_summary(
label = "Task 1: Chapter 17, problem 1c",
fit = fit_1c,
x_eval = mean(task_1c$x),
level_y = 0.95,
level_pred = 0.95
)
task_1d <- data.frame(
x = c(0, 1, 2, 3),
y = c(0, 2, 7, 5)
)
fit_1d <- fit_simple_regression(task_1d$x, task_1d$y, nu0 = -2, SS0 = 0)
print_regression_summary(
label = "Task 2: Chapter 17, problem 1d",
fit = fit_1d,
x_eval = mean(task_1d$x),
level_y = 0.90,
level_pred = 0.95
)
\end{minted}
\caption{R-kode for bokoppgavene 17.1c og 17.1d}
\label{lst:task12-r}
\end{listing}

View File

@@ -0,0 +1,72 @@
\section{Oppgave 2: Kapittel 17, oppgave 1d}
I denne oppgaven bruker vi observasjonene
\[
\{(0,0), (1,2), (2,7), (3,5)\},
\]
og vi antar nøytral prior for usikkerheten.
\subsection{Tema}
Temaet er Bayesiansk lineær regresjon når \(\sigma\) er ukjent. Da bruker vi de nøytrale
hyperparametrene fra boka.
\subsection{Prior og hyperparametre}
Ved nøytral prior setter vi
\[
\nu_0 = -2,
\qquad
SS_0 = 0.
\]
Dermed er det dataene alene som bestemmer posterioren.
\subsection{Posterior for \(\tau\)}
Posteriorfordelingen blir igjen
\[
\tau \mid \text{data} \sim \Gamma\!\left(\frac{\nu_1}{2}, \frac{SS_1}{2}\right),
\]
der \(\nu_1 = \nu_0 + n\) og \(SS_1 = SS_0 + SSe\).
\subsection{Posterior for \(y(x)\)}
For regresjonslinjen får vi
\[
y(x)\mid \text{data}
\sim
t\!\left(\alpha_0 + \beta x,\;
s_1\sqrt{\frac{1}{n} + \frac{(x-\bar{x})^2}{SS_x}},\;
\nu_1\right).
\]
\subsection{Prediktiv fordeling for \(Y_+(x)\)}
For en ny observasjon får vi
\[
Y_+(x)\mid \text{data}
\sim
t\!\left(\alpha_0 + \beta x,\;
s_1\sqrt{1 + \frac{1}{n} + \frac{(x-\bar{x})^2}{SS_x}},\;
\nu_1\right).
\]
\subsection{Intervallestimater}
Oppgaven ber om \(90\%\)-kredibilitetsintervall og \(95\%\)-prediktivt intervall. Disse blir
\[
I_{0.10}(x)
=
\alpha_0 + \beta x
\pm
t_{\nu_1,0.05}\,
s_1\sqrt{\frac{1}{n} + \frac{(x-\bar{x})^2}{SS_x}},
\]
og
\[
I^+_{0.05}(x)
=
\alpha_0 + \beta x
\pm
t_{\nu_1,0.025}\,
s_1\sqrt{1 + \frac{1}{n} + \frac{(x-\bar{x})^2}{SS_x}}.
\]
\subsection{Kommentar}
Forskjellen fra oppgave 1c er at vi nå ikke legger inn noen forhåndsinformasjon om
usikkerheten. Det gir en mer datadrevet analyse, og intervallene blir derfor bestemt av
spredningen i observasjonene alene.

View File

@@ -0,0 +1,197 @@
\section{Oppgave 3: Terningdropp}
\subsection{Tema}
Her studerer vi sammenhengen mellom dropphøyde \(x\) og hvor langt terningen spretter
ut fra veggen \(y\). Vi bruker nøytrale priorhyperparametre og analyserer datasettet med
Bayesiansk lineær regresjon.
\subsection{Datagrunnlag}
Dataene er hentet fra alle CSV-filene i mappen \texttt{terningDroppFiler}. Siden filene
bruker litt ulike kolonnenavn, er de først normalisert i R-skriptet slik at vi får felles
variabler for dropphøyde \(x\), sprettlengde \(y\) og terningverdi \(z\).
Listing~\ref{lst:task3-import} viser delen av skriptet som leser inn filene og standardiserer
kolonnenavnene før analysen.
\begin{listing}[H]
\begin{minted}{r}
read_dice_file <- function(path) {
raw_df <- read.csv(path, check.names = FALSE, fileEncoding = "UTF-8-BOM")
raw_df <- raw_df[, colSums(!is.na(raw_df)) > 0, drop = FALSE]
original_names <- names(raw_df)
clean_names <- vapply(original_names, standardize_name, character(1))
rename_map <- c(
"k" = "k",
"dropp" = "x",
"dropphoyde" = "x",
"x" = "x",
"lengde" = "y",
"sprettlengde" = "y",
"y" = "y",
"verdi" = "z",
"terningverdi" = "z",
"z" = "z",
"tid" = "t",
"t" = "t"
)
mapped_names <- rename_map[clean_names]
names(raw_df) <- ifelse(is.na(mapped_names), clean_names, mapped_names)
keep <- intersect(c("k", "x", "y", "z", "t"), names(raw_df))
out <- raw_df[, keep, drop = FALSE]
out$source_file <- basename(path)
for (name in setdiff(names(out), "source_file")) {
out[[name]] <- suppressWarnings(as.numeric(out[[name]]))
}
out
}
read_all_dice_data <- function(folder) {
files <- list.files(folder, pattern = "\\.csv$", full.names = TRUE)
df_list <- lapply(files, read_dice_file)
combined <- do.call(rbind, df_list)
rownames(combined) <- NULL
combined
}
\end{minted}
\caption{R-kode for innlesing og standardisering av terningdropp-data}
\label{lst:task3-import}
\end{listing}
\subsection{a) Punktsky og regresjonslinje}
Først tegnes alle datapunktene i et spredningsdiagram, og den lineære regresjonslinjen
legges oppå.
\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth]{images/task3_scatter_regression.png}
\caption{Punktsky for terningdropp med regresjonslinje.}
\end{figure}
\subsection{b) Posterior- og prediktive fordelinger}
Med nøytral prior setter vi
\[
\nu_0 = -2,
\qquad
SS_0 = 0.
\]
Da får vi posteriorfordelingene
\[
\tau \mid \text{data} \sim \Gamma\!\left(\frac{\nu_1}{2}, \frac{SS_1}{2}\right),
\]
\[
b \mid \text{data}
\sim
t\!\left(\beta,\; s_1 \sqrt{\frac{1}{SS_x}},\; \nu_1\right),
\]
\[
y(x)\mid \text{data}
\sim
t\!\left(\alpha_0 + \beta x,\;
s_1\sqrt{\frac{1}{n} + \frac{(x-\bar{x})^2}{SS_x}},\; \nu_1\right),
\]
og
\[
Y_+(x)\mid \text{data}
\sim
t\!\left(\alpha_0 + \beta x,\;
s_1\sqrt{1 + \frac{1}{n} + \frac{(x-\bar{x})^2}{SS_x}},\; \nu_1\right).
\]
Siden \(\sigma = 1/\sqrt{\tau}\), kan vi også utlede posterior usikkerhet for \(\sigma\).
\subsection{c) 80\% kredibilitetsintervall for stigningstallet \(b\)}
Intervallestimatet finnes fra posteriorfordelingen til \(b\):
\[
b \in
\left[
\beta - t_{\nu_1,0.1}\, s_1 \sqrt{\frac{1}{SS_x}},
\;
\beta + t_{\nu_1,0.1}\, s_1 \sqrt{\frac{1}{SS_x}}
\right].
\]
De numeriske verdiene leses ut fra R-skriptet.
\subsection{d) 80\% kredibilitetsintervall for standardavviket \(\sigma\)}
Her bruker vi sammenhengen mellom \(\sigma^2\) og \(\chi^2\)-fordelingen. Intervallet
kan beregnes direkte i R ut fra \(SS_1\) og \(\nu_1\).
\subsection{e) 80\% kredibilitetsintervall for \(y(x)\)}
For hver verdi av \(x\) får vi
\[
I_{0.20}(x)
=
\alpha_0 + \beta x
\pm
t_{\nu_1,0.1}\,
s_1\sqrt{\frac{1}{n} + \frac{(x-\bar{x})^2}{SS_x}}.
\]
\subsection{f) Kurver over og under regresjonslinjen}
Intervallet i punkt e) gir to kurver: en øvre og en nedre. Disse plottes sammen med
regresjonslinjen.
\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth]{images/task3_credible_band.png}
\caption{80\% kredibilitetsbånd for \(y(x)\).}
\end{figure}
\subsection{g) Forklaringsgrad \(R^2\)}
Forklaringsgraden
\[
R^2 = 1 - \frac{SSe}{SS_y}
\]
forteller hvor stor del av variasjonen i \(y\) som forklares av regresjonslinjen. Denne
kan enten beregnes direkte fra sums of squares eller hentes fra \texttt{lm()} i R.
\subsection{h) Regresjon mellom \(z\) og \(x\), og mellom \(t\) og \(x\)}
Oppgaven ber om en sammenligning av \(R^2\) for
\[
z \text{ mot } x
\qquad \text{og} \qquad
t \text{ mot } x.
\]
I de tilgjengelige CSV-filene finnes det tydelige kolonner for \(x\), \(y\) og \(z\), men
ingen entydig kolonne for \(t\). Derfor kan analysen for \(z\) gjennomføres direkte, mens
delen om \(t\) må enten utelates eller suppleres dersom tidsmålingene finnes i en annen fil.
\subsection{R-kode}
Listing~\ref{lst:task3-r} viser delen av skriptet som utfører regresjonen, skriver ut
intervallene og lager figurene til oppgave 3.
\begin{listing}[H]
\begin{minted}{r}
dice_df <- read_all_dice_data(file.path(script_dir, "terningDroppFiler"))
dice_df <- dice_df[complete.cases(dice_df[, intersect(c("x", "y", "z"), names(dice_df)), drop = FALSE]), ]
dice_fit <- fit_simple_regression(dice_df$x, dice_df$y, nu0 = -2, SS0 = 0)
x_grid <- seq(min(dice_df$x), max(dice_df$x), length.out = 300)
cred_band_80 <- credible_band(dice_fit, x_grid, level = 0.80)
pred_band_80 <- predictive_band(dice_fit, x_grid, level = 0.80)
cat("\nTask 3: Dice drop data\n")
cat("----------------------\n")
cat("Number of observations =", nrow(dice_df), "\n")
cat("Regression line: y =", round(dice_fit$alpha0, 4), "+", round(dice_fit$beta, 4), "* x\n")
cat("80% interval for b:", paste(round(b_interval(dice_fit, 0.80), 4), collapse = " to "), "\n")
cat("80% interval for sigma:", paste(round(sigma_interval(dice_fit, 0.80), 4), collapse = " to "), "\n")
cat("R^2 for y on x =", round(r_squared(dice_df$x, dice_df$y), 4), "\n")
cat("R^2 for z on x =", round(r_squared(dice_df$x, dice_df$z), 4), "\n")
plot_regression_with_band(
df = dice_df,
fit = dice_fit,
band_df = cred_band_80,
file_name = "task3_credible_band.png",
ylab = "Sprettlengde",
band_label = "Dice drop data with 80% credible band"
)
\end{minted}
\caption{R-kode for analyse og figurer i terningdropp-oppgaven}
\label{lst:task3-r}
\end{listing}

View File

@@ -0,0 +1,131 @@
\section{Oppgave 4: Utvalgsforsøk}
\subsection{Tema}
I denne delen undersøker vi hvordan regresjonslinjen og intervallestimatene endrer seg
når vi bare bruker tilfeldige delutvalg av observasjonene.
\subsection{a) 50 runder med \(N = 5\)}
Vi trekker 50 tilfeldige utvalg med \(N = 5\), finner regresjonslinjen for hvert utvalg,
og tegner alle linjene i samme figur.
\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth]{images/task4a_lines_N5.png}
\caption{50 regresjonslinjer basert på utvalg med \(N=5\).}
\end{figure}
Det vi forventer å se, er stor variasjon fra linje til linje fordi utvalgene er små.
\subsection{b) 50 runder med \(N = 15, 50, 200\)}
Vi gjentar samme prosedyre for større utvalg. Når \(N\) øker, bør linjene samle seg mer
rundt regresjonslinjen for hele datasettet.
\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth]{images/task4b_lines_N15.png}
\caption{Regresjonslinjer for \(N=15\).}
\end{figure}
\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth]{images/task4b_lines_N50.png}
\caption{Regresjonslinjer for \(N=50\).}
\end{figure}
\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth]{images/task4b_lines_N200.png}
\caption{Regresjonslinjer for \(N=200\).}
\end{figure}
\subsection{c) Oppgave 3c gjentatt 50 ganger med \(N = 5\)}
Her beregner vi 80\%-intervallestimatet for stigningstallet \(b\) i 50 runder med
\(N=5\), og tegner intervallene samlet i én figur.
\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth]{images/task4c_b_intervals_N5.png}
\caption{50 intervallestimater for \(b\) når \(N=5\).}
\end{figure}
Små utvalg vil typisk gi brede intervaller og stor variasjon mellom rundene.
\subsection{d) Samme analyse for \(N = 15, 50, 200\)}
Når vi øker \(N\), blir intervallene vanligvis smalere, og estimatene for \(b\) blir mer
stabile.
\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth]{images/task4d_b_intervals_N15.png}
\caption{Intervallestimater for \(b\) når \(N=15\).}
\end{figure}
\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth]{images/task4d_b_intervals_N50.png}
\caption{Intervallestimater for \(b\) når \(N=50\).}
\end{figure}
\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth]{images/task4d_b_intervals_N200.png}
\caption{Intervallestimater for \(b\) når \(N=200\).}
\end{figure}
\subsection{e) Illustrasjoner som i oppgave 3f}
Til slutt lager vi figurer med regresjonslinje og tilhørende 80\%-kredibilitetsbånd for
utvalg med \(N = 5, 15, 50\) og \(200\).
\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth]{images/task4e_bands_N5.png}
\caption{Kredibilitetsbånd for \(N=5\).}
\end{figure}
\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth]{images/task4e_bands_N15.png}
\caption{Kredibilitetsbånd for \(N=15\).}
\end{figure}
\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth]{images/task4e_bands_N50.png}
\caption{Kredibilitetsbånd for \(N=50\).}
\end{figure}
\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth]{images/task4e_bands_N200.png}
\caption{Kredibilitetsbånd for \(N=200\).}
\end{figure}
\subsection{Kommentar}
Hovedpoenget i denne oppgaven er å se hvordan usikkerheten minker når utvalgsstørrelsen
øker. Små utvalg gir mer ustabile linjer og bredere intervaller, mens store utvalg gir mer
presise estimater og tydeligere mønstre.
\subsection{R-kode}
Listing~\ref{lst:task4-r} viser delen av skriptet som trekker delutvalg og lager figurene
for oppgave 4.
\begin{listing}[H]
\begin{minted}{r}
plot_many_sample_lines(dice_df, sample_size = 5, rounds = 50, file_name = "task4a_lines_N5.png")
plot_many_sample_lines(dice_df, sample_size = 15, rounds = 50, file_name = "task4b_lines_N15.png")
plot_many_sample_lines(dice_df, sample_size = 50, rounds = 50, file_name = "task4b_lines_N50.png")
plot_many_sample_lines(dice_df, sample_size = 200, rounds = 50, file_name = "task4b_lines_N200.png")
plot_many_b_intervals(dice_df, sample_size = 5, rounds = 50, level = 0.80, file_name = "task4c_b_intervals_N5.png")
plot_many_b_intervals(dice_df, sample_size = 15, rounds = 50, level = 0.80, file_name = "task4d_b_intervals_N15.png")
plot_many_b_intervals(dice_df, sample_size = 50, rounds = 50, level = 0.80, file_name = "task4d_b_intervals_N50.png")
plot_many_b_intervals(dice_df, sample_size = 200, rounds = 50, level = 0.80, file_name = "task4d_b_intervals_N200.png")
plot_many_credible_bands(dice_df, sample_size = 5, rounds = 50, level = 0.80, file_name = "task4e_bands_N5.png")
plot_many_credible_bands(dice_df, sample_size = 15, rounds = 50, level = 0.80, file_name = "task4e_bands_N15.png")
plot_many_credible_bands(dice_df, sample_size = 50, rounds = 50, level = 0.80, file_name = "task4e_bands_N50.png")
plot_many_credible_bands(dice_df, sample_size = 200, rounds = 50, level = 0.80, file_name = "task4e_bands_N200.png")
\end{minted}
\caption{R-kode for gjentatte delutvalg og intervallillustrasjoner}
\label{lst:task4-r}
\end{listing}

394
Oblig/3c/oblig3c_analysis.R Normal file
View File

@@ -0,0 +1,394 @@
# Oblig 3c: Linear regression with uncertainty
options(stringsAsFactors = FALSE)
script_path_arg <- grep("^--file=", commandArgs(trailingOnly = FALSE), value = TRUE)
script_dir <- if (length(script_path_arg) > 0) {
dirname(normalizePath(sub("^--file=", "", script_path_arg[1])))
} else {
getwd()
}
output_dir <- file.path(script_dir, "output")
if (!dir.exists(output_dir)) {
dir.create(output_dir, recursive = TRUE)
}
# -----------------------------
# Generic helper functions
# -----------------------------
strip_bom <- function(x) {
sub("^\ufeff", "", x)
}
standardize_name <- function(x) {
cleaned <- tolower(strip_bom(iconv(x, to = "ASCII//TRANSLIT")))
cleaned <- gsub("[^a-z0-9]+", "", cleaned)
cleaned
}
read_dice_file <- function(path) {
raw_df <- read.csv(path, check.names = FALSE, fileEncoding = "UTF-8-BOM")
raw_df <- raw_df[, colSums(!is.na(raw_df)) > 0, drop = FALSE]
original_names <- names(raw_df)
clean_names <- vapply(original_names, standardize_name, character(1))
rename_map <- c(
"k" = "k",
"dropp" = "x",
"dropphoyde" = "x",
"x" = "x",
"lengde" = "y",
"sprettlengde" = "y",
"y" = "y",
"verdi" = "z",
"terningverdi" = "z",
"z" = "z",
"tid" = "t",
"t" = "t"
)
mapped_names <- rename_map[clean_names]
names(raw_df) <- ifelse(is.na(mapped_names), clean_names, mapped_names)
keep <- intersect(c("k", "x", "y", "z", "t"), names(raw_df))
out <- raw_df[, keep, drop = FALSE]
out$source_file <- basename(path)
for (name in setdiff(names(out), "source_file")) {
out[[name]] <- suppressWarnings(as.numeric(out[[name]]))
}
out
}
read_all_dice_data <- function(folder) {
files <- list.files(folder, pattern = "\\.csv$", full.names = TRUE)
df_list <- lapply(files, read_dice_file)
combined <- do.call(rbind, df_list)
rownames(combined) <- NULL
combined
}
fit_simple_regression <- function(x, y, nu0 = -2, SS0 = 0) {
stopifnot(length(x) == length(y))
n <- length(x)
x_bar <- mean(x)
x_centered <- x - x_bar
SSx <- sum(x_centered^2)
beta_hat <- sum(x_centered * y) / SSx
alpha_star <- mean(y)
alpha0 <- alpha_star - beta_hat * x_bar
fitted <- alpha0 + beta_hat * x
residuals <- y - fitted
SSe <- sum(residuals^2)
nu1 <- nu0 + n
SS1 <- SS0 + SSe
s1 <- sqrt(SS1 / nu1)
list(
n = n,
x = x,
y = y,
x_bar = x_bar,
SSx = SSx,
alpha0 = alpha0,
alpha_star = alpha_star,
beta = beta_hat,
fitted = fitted,
residuals = residuals,
SSe = SSe,
nu0 = nu0,
SS0 = SS0,
nu1 = nu1,
SS1 = SS1,
s1 = s1
)
}
tau_posterior_parameters <- function(fit) {
list(shape = fit$nu1 / 2, rate = fit$SS1 / 2)
}
sigma_interval <- function(fit, level = 0.80) {
alpha <- 1 - level
lower_var <- fit$SS1 / qchisq(1 - alpha / 2, df = fit$nu1)
upper_var <- fit$SS1 / qchisq(alpha / 2, df = fit$nu1)
c(lower = sqrt(lower_var), upper = sqrt(upper_var))
}
b_interval <- function(fit, level = 0.80) {
alpha <- 1 - level
t_crit <- qt(1 - alpha / 2, df = fit$nu1)
margin <- t_crit * fit$s1 / sqrt(fit$SSx)
c(lower = fit$beta - margin, upper = fit$beta + margin)
}
y_posterior_parameters <- function(fit, x_new) {
scale <- fit$s1 * sqrt(1 / fit$n + (x_new - fit$x_bar)^2 / fit$SSx)
list(mean = fit$alpha0 + fit$beta * x_new, scale = scale, df = fit$nu1)
}
y_predictive_parameters <- function(fit, x_new) {
scale <- fit$s1 * sqrt(1 + 1 / fit$n + (x_new - fit$x_bar)^2 / fit$SSx)
list(mean = fit$alpha0 + fit$beta * x_new, scale = scale, df = fit$nu1)
}
t_interval <- function(mean, scale, df, level) {
alpha <- 1 - level
t_crit <- qt(1 - alpha / 2, df = df)
c(lower = mean - t_crit * scale, upper = mean + t_crit * scale)
}
credible_band <- function(fit, x_grid, level = 0.80) {
alpha <- 1 - level
t_crit <- qt(1 - alpha / 2, df = fit$nu1)
mean_curve <- fit$alpha0 + fit$beta * x_grid
margin <- t_crit * fit$s1 * sqrt(1 / fit$n + (x_grid - fit$x_bar)^2 / fit$SSx)
data.frame(x = x_grid, mean = mean_curve, lower = mean_curve - margin, upper = mean_curve + margin)
}
predictive_band <- function(fit, x_grid, level = 0.80) {
alpha <- 1 - level
t_crit <- qt(1 - alpha / 2, df = fit$nu1)
mean_curve <- fit$alpha0 + fit$beta * x_grid
margin <- t_crit * fit$s1 * sqrt(1 + 1 / fit$n + (x_grid - fit$x_bar)^2 / fit$SSx)
data.frame(x = x_grid, mean = mean_curve, lower = mean_curve - margin, upper = mean_curve + margin)
}
r_squared <- function(x, y) {
fit <- lm(y ~ x)
summary(fit)$r.squared
}
print_regression_summary <- function(label, fit, x_eval = NULL, level_y = 0.80, level_pred = 0.80) {
tau_post <- tau_posterior_parameters(fit)
cat("\n", label, "\n", sep = "")
cat(strrep("-", nchar(label)), "\n", sep = "")
cat("n =", fit$n, "\n")
cat("x_bar =", fit$x_bar, "\n")
cat("alpha0 =", fit$alpha0, "\n")
cat("alpha* =", fit$alpha_star, "\n")
cat("beta =", fit$beta, "\n")
cat("SSe =", fit$SSe, "\n")
cat("Posterior tau ~ Gamma(shape =", tau_post$shape, ", rate =", tau_post$rate, ")\n")
if (!is.null(x_eval)) {
y_post <- y_posterior_parameters(fit, x_eval)
y_pred <- y_predictive_parameters(fit, x_eval)
cat("Posterior y(", x_eval, ") ~ t(mean =", y_post$mean, ", scale =", y_post$scale, ", df =", y_post$df, ")\n", sep = "")
cat("Predictive Y+(", x_eval, ") ~ t(mean =", y_pred$mean, ", scale =", y_pred$scale, ", df =", y_pred$df, ")\n", sep = "")
cat(level_y * 100, "% credible interval for y(", x_eval, "): ", paste(round(t_interval(y_post$mean, y_post$scale, y_post$df, level_y), 4), collapse = " to "), "\n", sep = "")
cat(level_pred * 100, "% predictive interval for Y+(", x_eval, "): ", paste(round(t_interval(y_pred$mean, y_pred$scale, y_pred$df, level_pred), 4), collapse = " to "), "\n", sep = "")
}
}
plot_regression_with_band <- function(df, fit, band_df, file_name, ylab, band_label) {
png(file.path(output_dir, file_name), width = 1200, height = 900, res = 150)
plot(df$x, df$y,
pch = 19, col = "black",
xlab = "x", ylab = ylab,
main = band_label)
lines(band_df$x, band_df$mean, col = "blue", lwd = 2)
lines(band_df$x, band_df$lower, col = "red", lwd = 2, lty = 2)
lines(band_df$x, band_df$upper, col = "red", lwd = 2, lty = 2)
dev.off()
}
plot_regression_only <- function(df, fit, file_name, ylab, plot_title) {
x_grid <- seq(min(df$x), max(df$x), length.out = 300)
png(file.path(output_dir, file_name), width = 1200, height = 900, res = 150)
plot(df$x, df$y,
pch = 19, col = "black",
xlab = "Dropphoyde", ylab = ylab,
main = plot_title)
lines(x_grid, fit$alpha0 + fit$beta * x_grid, col = "blue", lwd = 2)
dev.off()
}
plot_many_sample_lines <- function(df, sample_size, rounds, file_name) {
x_grid <- seq(min(df$x), max(df$x), length.out = 200)
full_fit <- fit_simple_regression(df$x, df$y)
png(file.path(output_dir, file_name), width = 1200, height = 900, res = 150)
plot(df$x, df$y,
pch = 19, col = "grey60",
xlab = "Dropphoyde", ylab = "Sprettlengde",
main = paste("Regression lines from", rounds, "random samples of size", sample_size))
for (i in seq_len(rounds)) {
sample_index <- sort(sample(seq_len(nrow(df)), sample_size))
sample_fit <- fit_simple_regression(df$x[sample_index], df$y[sample_index])
y_grid <- sample_fit$alpha0 + sample_fit$beta * x_grid
lines(x_grid, y_grid, col = rgb(1, 0, 0, alpha = 0.18), lwd = 1)
}
lines(x_grid, full_fit$alpha0 + full_fit$beta * x_grid, col = "blue", lwd = 3)
dev.off()
}
plot_many_b_intervals <- function(df, sample_size, rounds, level = 0.80, file_name) {
png(file.path(output_dir, file_name), width = 1200, height = 900, res = 150)
plot(NA,
xlim = c(0.5, rounds + 0.5),
ylim = range(vapply(seq_len(rounds), function(i) {
sample_index <- sort(sample(seq_len(nrow(df)), sample_size))
fit <- fit_simple_regression(df$x[sample_index], df$y[sample_index])
b_interval(fit, level)
}, numeric(2))),
xlab = "Runde", ylab = "Stigningstall b",
main = paste(round(level * 100), "% credible intervals for b,", "N =", sample_size))
for (i in seq_len(rounds)) {
sample_index <- sort(sample(seq_len(nrow(df)), sample_size))
fit <- fit_simple_regression(df$x[sample_index], df$y[sample_index])
interval <- b_interval(fit, level)
segments(i, interval["lower"], i, interval["upper"], col = "red", lwd = 2)
points(i, fit$beta, pch = 19, col = "blue")
}
abline(h = fit_simple_regression(df$x, df$y)$beta, col = "darkgreen", lwd = 2, lty = 2)
dev.off()
}
plot_many_credible_bands <- function(df, sample_size, rounds, level = 0.80, file_name) {
x_grid <- seq(min(df$x), max(df$x), length.out = 200)
png(file.path(output_dir, file_name), width = 1200, height = 900, res = 150)
plot(df$x, df$y,
pch = 19, col = "grey70",
xlab = "Dropphoyde", ylab = "Sprettlengde",
main = paste(round(level * 100), "% credible bands for y(x), N =", sample_size))
for (i in seq_len(rounds)) {
sample_index <- sort(sample(seq_len(nrow(df)), sample_size))
fit <- fit_simple_regression(df$x[sample_index], df$y[sample_index])
band <- credible_band(fit, x_grid, level)
lines(band$x, band$lower, col = rgb(1, 0, 0, alpha = 0.12), lwd = 1)
lines(band$x, band$upper, col = rgb(1, 0, 0, alpha = 0.12), lwd = 1)
}
full_fit <- fit_simple_regression(df$x, df$y)
lines(x_grid, full_fit$alpha0 + full_fit$beta * x_grid, col = "blue", lwd = 3)
dev.off()
}
# -----------------------------
# Book task 17.1c
# -----------------------------
task_1c <- data.frame(
x = c(2, 3, 4, 6),
y = c(10, 8, 8, 7)
)
fit_1c <- fit_simple_regression(task_1c$x, task_1c$y, nu0 = 4 - 2, SS0 = 0.5^2 * (4 - 2))
print_regression_summary(
label = "Task 1: Chapter 17, problem 1c",
fit = fit_1c,
x_eval = mean(task_1c$x),
level_y = 0.95,
level_pred = 0.95
)
# -----------------------------
# Book task 17.1d
# -----------------------------
task_1d <- data.frame(
x = c(0, 1, 2, 3),
y = c(0, 2, 7, 5)
)
fit_1d <- fit_simple_regression(task_1d$x, task_1d$y, nu0 = -2, SS0 = 0)
print_regression_summary(
label = "Task 2: Chapter 17, problem 1d",
fit = fit_1d,
x_eval = mean(task_1d$x),
level_y = 0.90,
level_pred = 0.95
)
# -----------------------------
# Dice-drop assignment
# -----------------------------
dice_df <- read_all_dice_data(file.path(script_dir, "terningDroppFiler"))
dice_df <- dice_df[complete.cases(dice_df[, intersect(c("x", "y", "z"), names(dice_df)), drop = FALSE]), ]
dice_fit <- fit_simple_regression(dice_df$x, dice_df$y, nu0 = -2, SS0 = 0)
x_grid <- seq(min(dice_df$x), max(dice_df$x), length.out = 300)
cred_band_80 <- credible_band(dice_fit, x_grid, level = 0.80)
pred_band_80 <- predictive_band(dice_fit, x_grid, level = 0.80)
cat("\nTask 3: Dice drop data\n")
cat("----------------------\n")
cat("Number of observations =", nrow(dice_df), "\n")
cat("Regression line: y =", round(dice_fit$alpha0, 4), "+", round(dice_fit$beta, 4), "* x\n")
cat("80% interval for b:", paste(round(b_interval(dice_fit, 0.80), 4), collapse = " to "), "\n")
cat("80% interval for sigma:", paste(round(sigma_interval(dice_fit, 0.80), 4), collapse = " to "), "\n")
cat("R^2 for y on x =", round(r_squared(dice_df$x, dice_df$y), 4), "\n")
cat("R^2 for z on x =", round(r_squared(dice_df$x, dice_df$z), 4), "\n")
if ("t" %in% names(dice_df)) {
cat("R^2 for t on x =", round(r_squared(dice_df$x, dice_df$t), 4), "\n")
} else {
cat("No time variable t was found in the CSV files, so task 3h can only be completed for z versus x with the current dataset.\n")
}
plot_regression_with_band(
df = dice_df,
fit = dice_fit,
band_df = cred_band_80,
file_name = "task3_credible_band.png",
ylab = "Sprettlengde",
band_label = "Dice drop data with 80% credible band"
)
plot_regression_only(
df = dice_df,
fit = dice_fit,
file_name = "task3_scatter_regression.png",
ylab = "Sprettlengde",
plot_title = "Dice drop data with regression line"
)
plot_regression_with_band(
df = dice_df,
fit = dice_fit,
band_df = pred_band_80,
file_name = "task3_predictive_band.png",
ylab = "Sprettlengde",
band_label = "Dice drop data with 80% predictive band"
)
# -----------------------------
# Repeated subsample experiments
# -----------------------------
set.seed(1234)
plot_many_sample_lines(dice_df, sample_size = 5, rounds = 50, file_name = "task4a_lines_N5.png")
plot_many_sample_lines(dice_df, sample_size = 15, rounds = 50, file_name = "task4b_lines_N15.png")
plot_many_sample_lines(dice_df, sample_size = 50, rounds = 50, file_name = "task4b_lines_N50.png")
plot_many_sample_lines(dice_df, sample_size = 200, rounds = 50, file_name = "task4b_lines_N200.png")
plot_many_b_intervals(dice_df, sample_size = 5, rounds = 50, level = 0.80, file_name = "task4c_b_intervals_N5.png")
plot_many_b_intervals(dice_df, sample_size = 15, rounds = 50, level = 0.80, file_name = "task4d_b_intervals_N15.png")
plot_many_b_intervals(dice_df, sample_size = 50, rounds = 50, level = 0.80, file_name = "task4d_b_intervals_N50.png")
plot_many_b_intervals(dice_df, sample_size = 200, rounds = 50, level = 0.80, file_name = "task4d_b_intervals_N200.png")
plot_many_credible_bands(dice_df, sample_size = 5, rounds = 50, level = 0.80, file_name = "task4e_bands_N5.png")
plot_many_credible_bands(dice_df, sample_size = 15, rounds = 50, level = 0.80, file_name = "task4e_bands_N15.png")
plot_many_credible_bands(dice_df, sample_size = 50, rounds = 50, level = 0.80, file_name = "task4e_bands_N50.png")
plot_many_credible_bands(dice_df, sample_size = 200, rounds = 50, level = 0.80, file_name = "task4e_bands_N200.png")
cat("\nTask 4 plots written to:", normalizePath(output_dir), "\n")

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 278 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 KiB

View File

@@ -0,0 +1,31 @@
K,Dropphoyde,Sprettlengde,Terningverdi
1,20,12.3,5
2,30,48.3,4
3,40,74.2,3
4,50,72.5,2
5,60,84.5,3
6,70,54.4,1
7,20,18.8,4
8,70,29.5,3
9,40,62.1,4
10,30,37.6,1
11,50,21.1,3
12,60,61.2,5
13,60,21.1,2
14,40,21.2,4
15,70,91.1,2
16,20,14.7,4
17,30,18.2,2
18,50,22.3,5
19,60,20.7,3
20,20,13.9,1
21,40,36.7,2
22,50,49.5,5
23,60,53.1,1
24,70,27.3,1
25,70,56.9,1
26,30,38.3,5
27,20,17.2,2
28,30,28.9,3
29,40,25.7,4
30,50,42.3,1
1 K Dropphoyde Sprettlengde Terningverdi
2 1 20 12.3 5
3 2 30 48.3 4
4 3 40 74.2 3
5 4 50 72.5 2
6 5 60 84.5 3
7 6 70 54.4 1
8 7 20 18.8 4
9 8 70 29.5 3
10 9 40 62.1 4
11 10 30 37.6 1
12 11 50 21.1 3
13 12 60 61.2 5
14 13 60 21.1 2
15 14 40 21.2 4
16 15 70 91.1 2
17 16 20 14.7 4
18 17 30 18.2 2
19 18 50 22.3 5
20 19 60 20.7 3
21 20 20 13.9 1
22 21 40 36.7 2
23 22 50 49.5 5
24 23 60 53.1 1
25 24 70 27.3 1
26 25 70 56.9 1
27 26 30 38.3 5
28 27 20 17.2 2
29 28 30 28.9 3
30 29 40 25.7 4
31 30 50 42.3 1

View File

@@ -0,0 +1,31 @@
k,Dropp,Lengde,Verdi
1,5,19,2
2,5,21,3
3,5,16,1
4,5,19,5
5,5,21,2
6,10,34,6
7,10,41,2
8,10,40,5
9,10,37,5
10,10,30,3
11,15,47,1
12,15,39,3
13,15,46,5
14,15,50,3
15,15,44,4
16,20,59,4
17,20,47,6
18,20,64,3
19,20,52,3
20,20,60,1
21,25,57,4
22,25,74,5
23,25,79,6
24,25,69,2
25,25,86,3
26,30,73,4
27,30,112,5
28,30,104,1
29,30,129,1
30,30,117,2
1 k Dropp Lengde Verdi
2 1 5 19 2
3 2 5 21 3
4 3 5 16 1
5 4 5 19 5
6 5 5 21 2
7 6 10 34 6
8 7 10 41 2
9 8 10 40 5
10 9 10 37 5
11 10 10 30 3
12 11 15 47 1
13 12 15 39 3
14 13 15 46 5
15 14 15 50 3
16 15 15 44 4
17 16 20 59 4
18 17 20 47 6
19 18 20 64 3
20 19 20 52 3
21 20 20 60 1
22 21 25 57 4
23 22 25 74 5
24 23 25 79 6
25 24 25 69 2
26 25 25 86 3
27 26 30 73 4
28 27 30 112 5
29 28 30 104 1
30 29 30 129 1
31 30 30 117 2

View File

@@ -0,0 +1,31 @@
k,Dropp,Lengde,Verdi
1,20,38,5
2,50,112,1
3,30,78,5
4,45,71,3
5,40,64,4
6,35,47,2
7,20,52,5
8,20,57,4
9,20,43,2
10,20,30,3
11,30,68,4
12,30,46,6
13,30,51,2
14,30,55,3
15,35,65,5
16,35,75,1
17,35,50,5
18,35,56,6
19,40,65,4
20,40,76,3
21,40,56,4
22,40,79,2
23,45,89,1
24,45,77,2
25,45,78,6
26,45,70,3
27,50,89,1
28,50,96,4
29,50,108,1
30,50,98,3
1 k Dropp Lengde Verdi
2 1 20 38 5
3 2 50 112 1
4 3 30 78 5
5 4 45 71 3
6 5 40 64 4
7 6 35 47 2
8 7 20 52 5
9 8 20 57 4
10 9 20 43 2
11 10 20 30 3
12 11 30 68 4
13 12 30 46 6
14 13 30 51 2
15 14 30 55 3
16 15 35 65 5
17 16 35 75 1
18 17 35 50 5
19 18 35 56 6
20 19 40 65 4
21 20 40 76 3
22 21 40 56 4
23 22 40 79 2
24 23 45 89 1
25 24 45 77 2
26 25 45 78 6
27 26 45 70 3
28 27 50 89 1
29 28 50 96 4
30 29 50 108 1
31 30 50 98 3

View File

@@ -0,0 +1,31 @@
k,Dropp,Lengde,Verdi
1,20,40.5,2
2,20,52,5
3,20,33,2
4,20,42.5,2
5,20,51,6
6,30,70.5,2
7,30,53.5,1
8,30,63,4
9,30,59,2
10,30,49.5,1
11,25,48.5,1
12,25,60.5,5
13,25,40,1
14,25,37.5,5
15,25,48,3
16,40,50,3
17,40,52.5,3
18,40,89.5,5
19,40,38.5,1
20,40,52.5,3
21,35,88,2
22,35,29,3
23,35,73,1
24,35,99.5,4
25,35,73,3
26,50,66,5
27,50,67,5
28,50,49,3
29,50,59,2
30,50,37.5,5
1 k Dropp Lengde Verdi
2 1 20 40.5 2
3 2 20 52 5
4 3 20 33 2
5 4 20 42.5 2
6 5 20 51 6
7 6 30 70.5 2
8 7 30 53.5 1
9 8 30 63 4
10 9 30 59 2
11 10 30 49.5 1
12 11 25 48.5 1
13 12 25 60.5 5
14 13 25 40 1
15 14 25 37.5 5
16 15 25 48 3
17 16 40 50 3
18 17 40 52.5 3
19 18 40 89.5 5
20 19 40 38.5 1
21 20 40 52.5 3
22 21 35 88 2
23 22 35 29 3
24 23 35 73 1
25 24 35 99.5 4
26 25 35 73 3
27 26 50 66 5
28 27 50 67 5
29 28 50 49 3
30 29 50 59 2
31 30 50 37.5 5

View File

@@ -0,0 +1,31 @@
k,x,y,z
1,5,13,1
2,8,32,1
3,10,30,2
4,10,25,1
5,10,35.5,4
6,10,26,4
7,10,20,3
8,11,22.5,2
9,12,26,6
10,13,31.5,2
11,13,24,4
12,14,30,6
13,15,34,2
14,15,40.5,1
15,16,45.5,3
16,17,24.5,4
17,18,40.5,6
18,18,46,2
19,19,50.5,3
20,20,66.5,6
21,21,87,4
22,21,39,6
23,22,57,1
24,23,67.5,5
25,24,34.5,1
26,25,45.5,6
27,26,63,3
28,27,61,5
29,30,61,1
30,30,86,5
1 k x y z
2 1 5 13 1
3 2 8 32 1
4 3 10 30 2
5 4 10 25 1
6 5 10 35.5 4
7 6 10 26 4
8 7 10 20 3
9 8 11 22.5 2
10 9 12 26 6
11 10 13 31.5 2
12 11 13 24 4
13 12 14 30 6
14 13 15 34 2
15 14 15 40.5 1
16 15 16 45.5 3
17 16 17 24.5 4
18 17 18 40.5 6
19 18 18 46 2
20 19 19 50.5 3
21 20 20 66.5 6
22 21 21 87 4
23 22 21 39 6
24 23 22 57 1
25 24 23 67.5 5
26 25 24 34.5 1
27 26 25 45.5 6
28 27 26 63 3
29 28 27 61 5
30 29 30 61 1
31 30 30 86 5

View File

@@ -0,0 +1,31 @@
k,Dropp,Lengde,Verdi
1,40,155,5
2,40,60,4
3,40,60,6
4,40,100,2
5,40,37,1
6,30,47,1
7,30,112,1
8,30,112,6
9,30,110,6
10,30,121,1
11,20,133,3
12,20,104,4
13,20,91,5
14,20,70,6
15,20,58,3
16,10,17,6
17,10,75,3
18,10,55,3
19,10,34,3
20,10,34,6
21,5,47,5
22,5,18,2
23,5,12,4
24,5,30,3
25,5,24,4
26,25,107,5
27,25,67,2
28,25,75,3
29,25,112,3
30,25,46,1
1 k Dropp Lengde Verdi
2 1 40 155 5
3 2 40 60 4
4 3 40 60 6
5 4 40 100 2
6 5 40 37 1
7 6 30 47 1
8 7 30 112 1
9 8 30 112 6
10 9 30 110 6
11 10 30 121 1
12 11 20 133 3
13 12 20 104 4
14 13 20 91 5
15 14 20 70 6
16 15 20 58 3
17 16 10 17 6
18 17 10 75 3
19 18 10 55 3
20 19 10 34 3
21 20 10 34 6
22 21 5 47 5
23 22 5 18 2
24 23 5 12 4
25 24 5 30 3
26 25 5 24 4
27 26 25 107 5
28 27 25 67 2
29 28 25 75 3
30 29 25 112 3
31 30 25 46 1

View File

@@ -0,0 +1,31 @@
k,Dropp,Lengde,Verdi
1,50,77,5
2,50,72.5,2
3,50,67,2
4,45,46,6
5,45,73.5,3
6,45,52,1
7,40,57,2
8,40,49,5
9,40,70,4
10,35,47.5,4
11,35,60,1
12,35,61,6
13,30,48,3
14,30,42,4
15,30,50,1
16,25,46,5
17,25,51,3
18,25,40,2
19,20,50,1
20,20,34,5
21,20,46,5
22,15,30,6
23,15,26,2
24,15,17,4
25,10,20,6
26,10,24,2
27,10,22,4
28,5,17,5
29,5,20,3
30,5,8,6
1 k Dropp Lengde Verdi
2 1 50 77 5
3 2 50 72.5 2
4 3 50 67 2
5 4 45 46 6
6 5 45 73.5 3
7 6 45 52 1
8 7 40 57 2
9 8 40 49 5
10 9 40 70 4
11 10 35 47.5 4
12 11 35 60 1
13 12 35 61 6
14 13 30 48 3
15 14 30 42 4
16 15 30 50 1
17 16 25 46 5
18 17 25 51 3
19 18 25 40 2
20 19 20 50 1
21 20 20 34 5
22 21 20 46 5
23 22 15 30 6
24 23 15 26 2
25 24 15 17 4
26 25 10 20 6
27 26 10 24 2
28 27 10 22 4
29 28 5 17 5
30 29 5 20 3
31 30 5 8 6

View File

@@ -0,0 +1,31 @@
k,Dropp,Lengde,Verdi
1,20,38,5
2,50,112,1
3,30,78,5
4,45,71,3
5,40,64,4
6,35,47,2
7,20,52,5
8,20,57,4
9,20,43,2
10,20,30,3
11,30,68,4
12,30,46,6
13,30,51,2
14,30,55,3
15,35,65,5
16,35,75,1
17,35,50,5
18,35,56,6
19,40,65,4
20,40,76,3
21,40,56,4
22,40,79,2
23,45,89,1
24,45,77,2
25,45,78,6
26,45,70,3
27,50,89,1
28,50,96,4
29,50,108,1
30,50,98,3
1 k Dropp Lengde Verdi
2 1 20 38 5
3 2 50 112 1
4 3 30 78 5
5 4 45 71 3
6 5 40 64 4
7 6 35 47 2
8 7 20 52 5
9 8 20 57 4
10 9 20 43 2
11 10 20 30 3
12 11 30 68 4
13 12 30 46 6
14 13 30 51 2
15 14 30 55 3
16 15 35 65 5
17 16 35 75 1
18 17 35 50 5
19 18 35 56 6
20 19 40 65 4
21 20 40 76 3
22 21 40 56 4
23 22 40 79 2
24 23 45 89 1
25 24 45 77 2
26 25 45 78 6
27 26 45 70 3
28 27 50 89 1
29 28 50 96 4
30 29 50 108 1
31 30 50 98 3

View File

@@ -0,0 +1,31 @@
k,Dropp,Lengde,Verdi
1,10,34,2
2,10,47,6
3,10,33.5,6
4,10,39,2
5,10,33,2
6,15,63.5,3
7,15,45,5
8,15,43.5,3
9,15,75,2
10,15,76,1
11,20,43,1
12,20,75,1
13,20,49,4
14,20,48.5,4
15,20,45,4
16,25,59,2
17,25,49,4
18,25,63,4
19,25,59,5
20,25,63,5
21,30,66,2
22,30,85,3
23,30,74,1
24,30,72,1
25,30,72.5,2
26,35,77,1
27,35,64,5
28,35,64.5,1
29,35,51.5,5
30,35,61.5,5
1 k Dropp Lengde Verdi
2 1 10 34 2
3 2 10 47 6
4 3 10 33.5 6
5 4 10 39 2
6 5 10 33 2
7 6 15 63.5 3
8 7 15 45 5
9 8 15 43.5 3
10 9 15 75 2
11 10 15 76 1
12 11 20 43 1
13 12 20 75 1
14 13 20 49 4
15 14 20 48.5 4
16 15 20 45 4
17 16 25 59 2
18 17 25 49 4
19 18 25 63 4
20 19 25 59 5
21 20 25 63 5
22 21 30 66 2
23 22 30 85 3
24 23 30 74 1
25 24 30 72 1
26 25 30 72.5 2
27 26 35 77 1
28 27 35 64 5
29 28 35 64.5 1
30 29 35 51.5 5
31 30 35 61.5 5

View File

@@ -0,0 +1,31 @@
k,Dropp,Lengde,Verdi
1,5,16,5
2,5,27,2
3,5,18,1
4,5,29,1
5,5,20,2
6,7,26,1
7,7,37,1
8,7,29,5
9,7,46,2
10,7,33,4
11,10,33,5
12,10,39,1
13,10,15,2
14,10,32,6
15,10,28,1
16,12,42,1
17,12,40,2
18,12,48,2
19,12,41,4
20,12,35,6
21,15,43,4
22,15,50,2
23,15,45,3
24,15,48,2
25,15,45,4
26,17,55,6
27,17,70,3
28,17,60,1
29,17,58,3
30,17,70,5
1 k Dropp Lengde Verdi
2 1 5 16 5
3 2 5 27 2
4 3 5 18 1
5 4 5 29 1
6 5 5 20 2
7 6 7 26 1
8 7 7 37 1
9 8 7 29 5
10 9 7 46 2
11 10 7 33 4
12 11 10 33 5
13 12 10 39 1
14 13 10 15 2
15 14 10 32 6
16 15 10 28 1
17 16 12 42 1
18 17 12 40 2
19 18 12 48 2
20 19 12 41 4
21 20 12 35 6
22 21 15 43 4
23 22 15 50 2
24 23 15 45 3
25 24 15 48 2
26 25 15 45 4
27 26 17 55 6
28 27 17 70 3
29 28 17 60 1
30 29 17 58 3
31 30 17 70 5

View File

@@ -0,0 +1,31 @@
k,Dropp,Lengde,Verdi
1,5,16,5
2,5,27,2
3,5,18,1
4,5,29,1
5,5,20,2
6,7,26,1
7,7,37,1
8,7,29,5
9,7,46,2
10,7,33,4
11,10,33,5
12,10,39,1
13,10,15,2
14,10,32,6
15,10,28,1
16,12,42,1
17,12,40,2
18,12,48,2
19,12,41,4
20,12,35,6
21,15,43,4
22,15,50,2
23,15,45,3
24,15,48,2
25,15,45,4
26,17,55,6
27,17,70,3
28,17,60,1
29,17,58,3
30,17,70,5
1 k Dropp Lengde Verdi
2 1 5 16 5
3 2 5 27 2
4 3 5 18 1
5 4 5 29 1
6 5 5 20 2
7 6 7 26 1
8 7 7 37 1
9 8 7 29 5
10 9 7 46 2
11 10 7 33 4
12 11 10 33 5
13 12 10 39 1
14 13 10 15 2
15 14 10 32 6
16 15 10 28 1
17 16 12 42 1
18 17 12 40 2
19 18 12 48 2
20 19 12 41 4
21 20 12 35 6
22 21 15 43 4
23 22 15 50 2
24 23 15 45 3
25 24 15 48 2
26 25 15 45 4
27 26 17 55 6
28 27 17 70 3
29 28 17 60 1
30 29 17 58 3
31 30 17 70 5

View File

@@ -0,0 +1,31 @@
k,x,y,z
1,35,115,5
2,15,23,2
3,10,23,6
4,30,79,3
5,25,65,3
6,20,27,2
7,25,48,6
8,35,91,4
9,20,73,1
10,25,31,6
11,30,88,1
12,25,36,4
13,10,27,2
14,25,40,3
15,35,75,2
16,15,60,1
17,10,18,6
18,30,65,3
19,20,30,1
20,35,55,6
21,15,25,2
22,15,45,1
23,30,50,5
24,35,118,3
25,10,18,4
26,20,40,6
27,20,25,6
28,15,59,2
29,10,29,2
30,30,50,3
1 k x y z
2 1 35 115 5
3 2 15 23 2
4 3 10 23 6
5 4 30 79 3
6 5 25 65 3
7 6 20 27 2
8 7 25 48 6
9 8 35 91 4
10 9 20 73 1
11 10 25 31 6
12 11 30 88 1
13 12 25 36 4
14 13 10 27 2
15 14 25 40 3
16 15 35 75 2
17 16 15 60 1
18 17 10 18 6
19 18 30 65 3
20 19 20 30 1
21 20 35 55 6
22 21 15 25 2
23 22 15 45 1
24 23 30 50 5
25 24 35 118 3
26 25 10 18 4
27 26 20 40 6
28 27 20 25 6
29 28 15 59 2
30 29 10 29 2
31 30 30 50 3

View File

@@ -0,0 +1,31 @@
k,Dropphoyde,Sprettlengde,Terningverdi
1,18,64,1
2,34,98,6
3,9,39,5
4,34,120,5
5,15,36,1
6,18,63,1
7,34,87,2
8,5,29,5,
9,18,66,5
10,34,84,2
11,15,89,6
12,15,43,4
13,21,88,3
14,9,34,2
15,21,64,3
16,5,37,2
17,9,33,4
18,5,46,5
19,18,61,6
20,15,36,1
21,21,80,3
22,21,73,1
23,9,31,3
24,5,35,5,
25,34,121,1
26,18,63,5
27,5,37,5,
28,9,26,6
29,21,93,6
30,15,39,6
1 k,Dropphoyde,Sprettlengde,Terningverdi
2 1,18,64,1
3 2,34,98,6
4 3,9,39,5
5 4,34,120,5
6 5,15,36,1
7 6,18,63,1
8 7,34,87,2
9 8,5,29,5,
10 9,18,66,5
11 10,34,84,2
12 11,15,89,6
13 12,15,43,4
14 13,21,88,3
15 14,9,34,2
16 15,21,64,3
17 16,5,37,2
18 17,9,33,4
19 18,5,46,5
20 19,18,61,6
21 20,15,36,1
22 21,21,80,3
23 22,21,73,1
24 23,9,31,3
25 24,5,35,5,
26 25,34,121,1
27 26,18,63,5
28 27,5,37,5,
29 28,9,26,6
30 29,21,93,6
31 30,15,39,6

View File

@@ -0,0 +1,31 @@
k,Dropphoyde,Lengde,Verdi
1,25,34,5
2,40,39,3
3,10,11.3,2
4,15,16.8,2
5,30,35,4
6,10,13.3,1
7,10,8.8,4
8,10,9.9,4
9,15,19.8,2
10,15,15.7,5
11,15,20.6,2
12,20,18.8,3
13,20,26.7,4
14,20,24.4,1
15,20,25.5,4
16,25,24.8,1
17,25,19.1,2
18,25,19.8,1
19,30,37.6,2
20,30,43.9,5
21,30,49.7,5
22,35,47.4,1
23,35,35.3,6
24,35,35.6,1
25,35,44.2,4
26,40,57.6,1
27,40,33.9,2
28,40,40.2,3
29,5,9.7,3
30,5,12,1
1 k Dropphoyde Lengde Verdi
2 1 25 34 5
3 2 40 39 3
4 3 10 11.3 2
5 4 15 16.8 2
6 5 30 35 4
7 6 10 13.3 1
8 7 10 8.8 4
9 8 10 9.9 4
10 9 15 19.8 2
11 10 15 15.7 5
12 11 15 20.6 2
13 12 20 18.8 3
14 13 20 26.7 4
15 14 20 24.4 1
16 15 20 25.5 4
17 16 25 24.8 1
18 17 25 19.1 2
19 18 25 19.8 1
20 19 30 37.6 2
21 20 30 43.9 5
22 21 30 49.7 5
23 22 35 47.4 1
24 23 35 35.3 6
25 24 35 35.6 1
26 25 35 44.2 4
27 26 40 57.6 1
28 27 40 33.9 2
29 28 40 40.2 3
30 29 5 9.7 3
31 30 5 12 1

View File

@@ -0,0 +1,31 @@
k,Dropp,Lengde,Verdi,
1,27.50,27,4,
2,9.5,38,1,
3,24,128,3,
4,45,59,1,
5,42,76,1,
6,27.50,59.5,3,
7,27.5,99.5,4,
8,27.5,66,2,
9,27.5,85.5,5,
10,9.5,22,6,
11,9.5,37,5,
12,9.5,48.5,6,
13,9.5,57.5,1,
14,24,77.5,4,
15,24,104,6,
16,24,93.5,3,
17,24,84,2,
18,42,105,4,
19,42,59,1,
20,42,66,2,
21,42,240,2,
22,14,52.5,3,
23,14,46,1,
24,14,42,2,
25,14,67,5,
26,14,48,1,
27,4.5,18,4,
28,4.5,21,2,
29,4.5,20,2,
30,4.5,27,5,
1 k Dropp Lengde Verdi
2 1 27.50 27 4
3 2 9.5 38 1
4 3 24 128 3
5 4 45 59 1
6 5 42 76 1
7 6 27.50 59.5 3
8 7 27.5 99.5 4
9 8 27.5 66 2
10 9 27.5 85.5 5
11 10 9.5 22 6
12 11 9.5 37 5
13 12 9.5 48.5 6
14 13 9.5 57.5 1
15 14 24 77.5 4
16 15 24 104 6
17 16 24 93.5 3
18 17 24 84 2
19 18 42 105 4
20 19 42 59 1
21 20 42 66 2
22 21 42 240 2
23 22 14 52.5 3
24 23 14 46 1
25 24 14 42 2
26 25 14 67 5
27 26 14 48 1
28 27 4.5 18 4
29 28 4.5 21 2
30 29 4.5 20 2
31 30 4.5 27 5

View File

@@ -0,0 +1,31 @@
k,Dropp,Lengde,Verdi
1,5,24.2,1
2,5,19.4,1
3,5,22,4
4,5,16.8,6
5,5,21.2,3
6,10,44.8,4
7,10,31.5,2
8,10,33.6,5
9,10,28,3
10,10,32.5,6
11,15,60,6
12,15,72.4,4
13,15,55.9,6
14,15,47.3,6
15,15,44.8,5
16,20,56.5,3
17,20,49.7,1
18,20,74.6,5
19,20,63,1
20,20,68.8,2
21,25,89,1
22,25,71.3,3
23,25,95.8,4
24,25,76.1,3
25,25,64.5,3
26,30,101.5,6
27,30,110,5
28,30,74.5,6
29,30,110.5,6
30,30,75.4,4
1 k Dropp Lengde Verdi
2 1 5 24.2 1
3 2 5 19.4 1
4 3 5 22 4
5 4 5 16.8 6
6 5 5 21.2 3
7 6 10 44.8 4
8 7 10 31.5 2
9 8 10 33.6 5
10 9 10 28 3
11 10 10 32.5 6
12 11 15 60 6
13 12 15 72.4 4
14 13 15 55.9 6
15 14 15 47.3 6
16 15 15 44.8 5
17 16 20 56.5 3
18 17 20 49.7 1
19 18 20 74.6 5
20 19 20 63 1
21 20 20 68.8 2
22 21 25 89 1
23 22 25 71.3 3
24 23 25 95.8 4
25 24 25 76.1 3
26 25 25 64.5 3
27 26 30 101.5 6
28 27 30 110 5
29 28 30 74.5 6
30 29 30 110.5 6
31 30 30 75.4 4

View File

@@ -0,0 +1,31 @@
k,Dropp,Lengde,Verdi
1,5,36,5
2,10,57,5
3,15,50,4
4,20,87,4
5,25,78,4
6,5,26,3
7,10,61,4
8,10,32,5
9,10,52,3
10,5,24,1
11,15,67,2
12,15,49,3
13,15,60,6
14,15,38,3
15,5,27,5
16,20,107,4
17,20,91,4
18,20,118,3
19,20,57,2
20,10,31,2
21,25,77,4
22,25,77,5
23,25,98,6
24,25,109,1
25,5,26,5
26,30,75,3
27,30,128,5
28,30,144,2
29,30,94,3
30,30,125,5
1 k Dropp Lengde Verdi
2 1 5 36 5
3 2 10 57 5
4 3 15 50 4
5 4 20 87 4
6 5 25 78 4
7 6 5 26 3
8 7 10 61 4
9 8 10 32 5
10 9 10 52 3
11 10 5 24 1
12 11 15 67 2
13 12 15 49 3
14 13 15 60 6
15 14 15 38 3
16 15 5 27 5
17 16 20 107 4
18 17 20 91 4
19 18 20 118 3
20 19 20 57 2
21 20 10 31 2
22 21 25 77 4
23 22 25 77 5
24 23 25 98 6
25 24 25 109 1
26 25 5 26 5
27 26 30 75 3
28 27 30 128 5
29 28 30 144 2
30 29 30 94 3
31 30 30 125 5

View File

@@ -0,0 +1,31 @@
k,Dropp,Lengde,Verdi
1,50,111,2
2,45,101,3
3,40,51,3
4,35,50,1
5,30,45.5,6
6,33,50.5,3
7,26,77.5,1
8,15,20,3
9,23,45,5
10,42,97.5,4
11,58,89,4
12,27,62,2
13,17,47,3
14,19,37.5,3
15,37,57,6
16,50,135,6
17,45,69,6
18,40,51,3
19,35,85.2,2
20,30,65,3
21,33,25.5,3
22,26,33,3
23,15,23,2
24,23,64,4
25,42,60.5,2
26,58,65.5,4
27,27,42,3
28,17,27.5,6
29,19,13.5,1
30,37,68,1
1 k Dropp Lengde Verdi
2 1 50 111 2
3 2 45 101 3
4 3 40 51 3
5 4 35 50 1
6 5 30 45.5 6
7 6 33 50.5 3
8 7 26 77.5 1
9 8 15 20 3
10 9 23 45 5
11 10 42 97.5 4
12 11 58 89 4
13 12 27 62 2
14 13 17 47 3
15 14 19 37.5 3
16 15 37 57 6
17 16 50 135 6
18 17 45 69 6
19 18 40 51 3
20 19 35 85.2 2
21 20 30 65 3
22 21 33 25.5 3
23 22 26 33 3
24 23 15 23 2
25 24 23 64 4
26 25 42 60.5 2
27 26 58 65.5 4
28 27 27 42 3
29 28 17 27.5 6
30 29 19 13.5 1
31 30 37 68 1

View File

@@ -0,0 +1,31 @@
k,x,y,z
1,20,42,1
2,10,41,3
3,50,45,2
4,30,34,4
5,20,37,3
6,40,73,4
7,50,171,3
8,60,137,4
9,10,39,4
10,40,57,1
11,30,122,4
12,30,75,5
13,10,26,6
14,60,102,5
15,40,160,3
16,20,50,5
17,60,63,1
18,50,90,5
19,40,104,3
20,30,128,2
21,20,75,6
22,10,37,4
23,50,48,4
24,40,86,3
25,60,72,4
26,10,43,4
27,20,68,1
28,30,44,5
29,50,107,1
30,60,65,5
1 k x y z
2 1 20 42 1
3 2 10 41 3
4 3 50 45 2
5 4 30 34 4
6 5 20 37 3
7 6 40 73 4
8 7 50 171 3
9 8 60 137 4
10 9 10 39 4
11 10 40 57 1
12 11 30 122 4
13 12 30 75 5
14 13 10 26 6
15 14 60 102 5
16 15 40 160 3
17 16 20 50 5
18 17 60 63 1
19 18 50 90 5
20 19 40 104 3
21 20 30 128 2
22 21 20 75 6
23 22 10 37 4
24 23 50 48 4
25 24 40 86 3
26 25 60 72 4
27 26 10 43 4
28 27 20 68 1
29 28 30 44 5
30 29 50 107 1
31 30 60 65 5