From 62805dc79e743abea6f29de2bb2ed0ed61209830 Mon Sep 17 00:00:00 2001
From: Jaroslav Borodavka <df2994@kit.edu>
Date: Wed, 17 Apr 2024 09:48:42 +0200
Subject: [PATCH] Added/changed comments.

---
 R/Local_Bahadur_ARE.R                    | 25 +++++++++++++++++++-----
 R/T_Statistic_GP_viaSphericalHarmonics.R |  2 +-
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/R/Local_Bahadur_ARE.R b/R/Local_Bahadur_ARE.R
index 8ffe317..58c28d4 100644
--- a/R/Local_Bahadur_ARE.R
+++ b/R/Local_Bahadur_ARE.R
@@ -1,13 +1,24 @@
+#################################################################################################
+#################################################################################################
+## This script computes the local Bahadur ARE of T with respect to three different alternative
+## classes which where considered and analyzed in the examples at the end of section 5 of the
+## main manuscript. For each calculation a latex table via package 'xtable' is created.
+#################################################################################################
+#################################################################################################
+
+# required packages
 library(Directional)
 library(MASS)
 library(MonteCarlo)
 library(data.table)
+library(xtable)     # creates tables in form of latex code
 
-setwd("/Users/faik/Desktop/Mathematik/Masterarbeit/Ansatz_2/R-Codes")
+setwd("/home/jaroslav-borodavka/Schreibtisch/Dissertation/Arbeit/Bernoulli Submission/codes/codes_git_project/R")
 
 #################################################################################################
-## Funktionen ## 
+## functions ## 
 
+# eigenvalues as in the end of section 2 of the main manuscript, beta <= 6
 eigenvalue <- function(beta, d){
   eigenvalue_list = switch (beta,
                             c(1/d^2 ),
@@ -20,10 +31,12 @@ eigenvalue <- function(beta, d){
   return(eigenvalue_list)
 }
 
+# dimension of the space of d-dimensional spherical harmonics of order k
 dim_Har <- function(k, d){
   return(if (k==0 & d==2) 1 else (2*k+d-2)/(k+d-2)*choose(k+d-2, d-2))
 }
 
+# local Bahadur ARE of T with respect to the von Mises-Fisher alternative
 local_bahadur_ARE_vMF <- function(beta, d){
   ev = eigenvalue(beta, d)
   lambda_1 = ev[1]
@@ -34,6 +47,7 @@ local_bahadur_ARE_vMF <- function(beta, d){
   return(lambda_1*dim_Har(1, d)/summe)
 }
 
+# local Bahadur ARE of T with respect to the Watson alternative
 local_bahadur_ARE_W <- function(beta, d){
   ev = eigenvalue(beta, d)
   lambda_2 = ev[2]
@@ -49,6 +63,7 @@ local_bahadur_ARE_W <- function(beta, d){
   }
 }
 
+# local Bahadur ARE of T with respect to the Legendre polynomial alternative
 local_bahadur_ARE_LP <- function(beta, d, m){
   ev = eigenvalue(beta, d)
   lambda_m = ev[m]
@@ -65,7 +80,7 @@ local_bahadur_ARE_LP <- function(beta, d, m){
 }
 
 #################################################################################################
-## vMF Alternative ## 
+## vMF alternative ## 
 
 DT_Bahadur_ARE_vMF = data.table(Beta = rep(seq(1, 6), each = 4), dim = c(2,3,5,10))
 DT_Bahadur_ARE_vMF[, grp := .GRP, by = c("Beta", "dim")][, ARE := round(local_bahadur_ARE_vMF(Beta, dim), digits = 2), by = grp][, grp := NULL][]
@@ -92,7 +107,7 @@ print(mat_Bahadur_ARE_vMF)
 print(xtable(mat_Bahadur_ARE_vMF, type = "latex"))
 
 #################################################################################################
-## W Alternative ## 
+## W alternative ## 
 
 DT_Bahadur_ARE_W = data.table(Beta = rep(seq(1, 6), each = 4), dim = c(2,3,5,10))
 DT_Bahadur_ARE_W[, grp := .GRP, by = c("Beta", "dim")][, ARE := round(local_bahadur_ARE_W(Beta, dim), digits = 2), by = grp][, grp := NULL][]
@@ -119,7 +134,7 @@ print(mat_Bahadur_ARE_W)
 print(xtable(mat_Bahadur_ARE_W, type = "latex"))
 
 #################################################################################################
-## LP Alternative ## 
+## LP alternative ## 
 
 DT_Bahadur_ARE_LP = data.table(Beta = rep(seq(1, 6), each = 4), m = rep(seq(1, 6), each = 24), dim = c(2,3,5,10))
 DT_Bahadur_ARE_LP[, grp := .GRP, by = c("Beta", "dim", "m")][, ARE := round(local_bahadur_ARE_LP(Beta, dim, m), digits = 2), by = grp][, grp := NULL][]
diff --git a/R/T_Statistic_GP_viaSphericalHarmonics.R b/R/T_Statistic_GP_viaSphericalHarmonics.R
index 4410457..282abc1 100644
--- a/R/T_Statistic_GP_viaSphericalHarmonics.R
+++ b/R/T_Statistic_GP_viaSphericalHarmonics.R
@@ -40,7 +40,7 @@ surface_area <- function(d){
   return(2*pi^(d/2)/gamma(d/2))
 }
 
-# eigenvalues as in the end of section 2 of the main manuscript
+# eigenvalues as in the end of section 2 of the main manuscript, beta <= 6
 eigenvalue <- function(beta, d){
   eigenvalue_list = switch (beta,
                       c(0, 1/d^2 ),
-- 
GitLab