#!/usr/bin/Rscript args <- commandArgs(TRUE); tag <- args[1]; file_prefix <- args[2]; title <- args[3]; data <- read.csv(file("stdin")); times <- data$EPOCH; clap <- data$CLAP; psap <- data$PSAP; weighting_function <- function(values) { #q <- quantile(values, probs=c(0.05, 0.95), na.rm=TRUE); #w <- (values - q[1]) / (q[2] - q[1]); #w[is.finite(w) & (w < 0)] <- 0; #w[is.finite(w) & (w > 0)] <- 1; #w[is.finite(values) & values < 0] <- 0; #w <- w * 0.9 + 0.1; w <- 1 / (2*sqrt( (0.05)^2 + (0.024 / values)^2 )); w[!is.finite(w)] <- 0; return (w); } # Use the least weight between the two weights <- pmin( weighting_function(clap), weighting_function(psap) ); selected_data <- sample(length(clap), length(clap) * 10, replace=TRUE, prob=weights); times <- times[selected_data]; clap <- clap[selected_data]; psap <- psap[selected_data]; source("code/output_fits.r"); # Currently disabled: use the fully filtered PCA data for distribution generation #psap <- result$pcafilter$matrix[,1]; #clap <- result$pcafilter$matrix[,2]; source("code/output_distributions.r");