Skip to content

MeetDarkPow/GSOC-2020

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 

Repository files navigation

Asymptotic Complexity Testing - GSOC 2020

Packages used in these tests are as follows:

  • PeakSegDP
  • PeakSegOptimal
  • tidyverse (ggplot2)
  • microbenchmark

Easy Test

#################### Easy Test ####################

# Load these libraries

library(microbenchmark)
library(PeakSegDP)
library(PeakSegOptimal)
library(ggplot2)

# Taking input to create user friendly data set 

N <- as.integer(readline(prompt="Enter size of Data set: "))
test_size_value <- c(N, 10*N, 100*N, 1000*N)

# Two empty variables to hold computation time

cdpa <- integer(length(test_size_value))
pdpa <- integer(length(test_size_value))

# Function to calculate computation time of cDPA() and PeakSegPDPA() Function
# computation_time function 2 parameters.
# First  -> ms which corresponds to number of max segements
# Second -> lambda which corresponds to vector of means

computation_time <- function(ms, lambda) {
  # for() loop used to compute each set computation time
  for (i in 1:length(test_size_value)) {
    mbm <- microbenchmark(cDPA(rpois(test_size_value[i], lambda), maxSegments = as.integer(ms)),
                          PeakSegPDPA(rpois(test_size_value[i], lambda), max.segments = as.integer(ms)))
    execution_time <- summary(mbm)$mean   # Extracting computation time
    cdpa[i] <<- execution_time[1]         # Storing extracted computation time 
    pdpa[i] <<- execution_time[2]         # Storing extracted computation time 
  }
}

# Function for plotting graph of PeakSegDP::cDPA versus PeakSegOptimal::PeakSegPDPA
# computation_graph has 1 parameter
# First -> number of data sets we want to display

computation_graph <- function(sets) {
  coord <- data.frame(cdpa, pdpa, test_size_value)  
  ggplot(coord, aes(test_size_value)) + 
    geom_line(aes(y = cdpa, colour = "cDPA")) + 
    geom_line(aes(y = pdpa, colour = "PeakSegPDPA")) +
    ggtitle("PeakSegDP::cDPA versus PeakSegOptimal::PeakSegPDPA") +
    theme(plot.title = element_text(hjust = 0.5)) +
    scale_x_log10() + scale_y_log10() +
    xlab("N") + labs(colour = "Function Comparison") + 
    ylab("Execution Time") + 
    theme_bw(base_size = 15) + 
    geom_point(aes(y = cdpa, colour = "cDPA"), size=2, shape=19) +
    geom_point(aes(y = pdpa, colour = "PeakSegPDPA"), size=2, shape=19)
}

Output Plot:

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages