Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • 80ec129
  • /
  • 4-Abs-and-True-error-by-percent_1.R
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge
swh:1:cnt:98fcbd69be41310995302b191a61a6c85ae7f6d8
directory badge
swh:1:dir:80ec129a4c99986d066f19504df5478656e66f55

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
4-Abs-and-True-error-by-percent_1.R
library(plyr)
library(dplyr)
library(MPDiR)
library(quickpsy)
library(fitdistrplus)
library(ggplot2)
library(tidyverse)  

source("1-read-and-calculate_errors_time_1.R") # to read global values
source("CI-Functions-Bonferroni.R")

# set directory where script is
sourceDir <- dirname (rstudioapi::getActiveDocumentContext()$path) 
defaultpath <- sourceDir

#remove(list = ls())
print(defaultpath)
setwd(defaultpath)

filename <- "results/aggregated_per_percentage.csv"
dataFile <- read.csv(filename)

aggregatedstable <-dataFile

if (exists ("all_percentage_CIs")) { rm(all_percentage_CIs) }


# calculate CIs for each percentage and vis speed

# tmp_data <- aggregatedstable [ which ((aggregatedstable$correct_answer == '18') & 
#                                         (aggregatedstable$speed_duration == '0-static')),]
# 
# tmp_abs_error <- bootstrapMeanCI(tmp_data[,"mean_abs_error"])
# tmp = data.frame (correct_answer = '18',  speed_duration = '0-static', 
#         mean_abs_error = tmp_abs_error[1], 
#         lowci_abs_error = tmp_abs_error[2], 
#         upci_abs_error = tmp_abs_error[3])
# 
# if ( !exists("all_percentage_CIs") ){
#   all_percentage_CIs <- tmp
#   }else{
#   all_percentage_CIs <- rbind(all_percentage_CIs,tmp)
# }

correct_answer_interest <- c(18,32,43,58,72,83)

for(per in correct_answer_interest)
  for (vis in speed_duration)
  {
    tmp_data <- aggregatedstable [ which ((aggregatedstable$correct_answer == per) & 
                                            (aggregatedstable$speed_duration == vis)),]
    
    tmp_abs_error <- bootstrapMeanCI(tmp_data[,"mean_abs_error"])
    tmp_true_error <- bootstrapMeanCI(tmp_data[,"mean_true_error"])
    tmp = data.frame (correct_answer = per,  speed_duration = vis, 
                      mean_abs_error = tmp_abs_error[1], 
                      lowci_abs_error = tmp_abs_error[2], 
                      upci_abs_error = tmp_abs_error[3],
                      mean_true_error = tmp_true_error[1], 
                      lowci_true_error = tmp_true_error[2], 
                      upci_true_error = tmp_true_error[3])
    
    if ( !exists("all_percentage_CIs") ){
      all_percentage_CIs <- tmp
    }else{
      all_percentage_CIs <- rbind(all_percentage_CIs,tmp)
    }
  }




ggplot(all_percentage_CIs, aes(correct_answer, mean_abs_error, colour=speed_duration)) + 
  theme_bw()+
  geom_line() + 
  geom_point() +
  xlab('True percentage')+ ylab('Absolute Error')+
  geom_linerange (aes(ymin=lowci_abs_error,ymax=upci_abs_error))
#  geom_ribbon (aes(ymin=lowci_abs_error,ymax=upci_abs_error, fill = speed_duration),alpha = 0.3)
ggsave("plots/abs-errors-per-percentage.pdf",device = pdf, width=5, height=2)

ggplot(all_percentage_CIs, aes(correct_answer, mean_true_error, colour=speed_duration)) + 
  theme_bw()+
  geom_line() + 
  geom_point() +
  xlab('True percentage')+ ylab('Error')+
  geom_linerange (aes(ymin=lowci_true_error,ymax=upci_true_error))
#  geom_ribbon (aes(ymin=lowci_true_error,ymax=upci_true_error, fill = speed_duration),alpha = 0.3)
ggsave("plots/true-errors-per-percentage.pdf",device = pdf, width=5, height=2)

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API