This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String toRoundedString(double[] a) { | |
if (a == null) | |
return "null"; | |
int iMax = a.length - 1; | |
if (iMax == -1) | |
return "[]"; | |
StringBuilder b = new StringBuilder(); | |
b.append('['); | |
for (int i = 0; ; i++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plot_bar <- function(vals, title = "Histogram") { | |
fdf <- as.data.frame(vals) | |
pl <- (ggplot(fdf,aes(x=1:nrow(fdf),y=vals,ymin=0,ymax=vals)) | |
+ geom_bar(colour="white",fill="blue",stat="identity") | |
+ ggtitle(title) | |
+ theme(plot.title=element_text(family="Arial", size=10)) | |
+ theme(axis.text.x = element_text(angle = 90, hjust = 1)) | |
) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' plot_df_dists | |
#' | |
#' Takes a dataframe and produces plots of the distributions of | |
#' all variables in the dataframe. Variables containing only | |
#' unique values should be filtered out before calling this | |
#' function since it is quite pointless plotting distributions | |
#' for these types of variables and it takes a long time too | |
#' | |
#' @param df input data frame | |
#' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plot_dist <- function(dist_fun, dist_args, range) { | |
pl <- ggplot(data = data.frame(x = range), aes(x)) + | |
stat_function(fun = dist_fun, n = 101, args = dist_args) + ylab("") + | |
scale_y_continuous(breaks = NULL) | |
} | |
plot_overlay_dist <- function(dist_funs, dist_args, range) { | |
pl <- ggplot(data = data.frame(x = range), aes(x)) + scale_y_continuous(breaks = NULL) | |
fcnt <- 1; | |
for(dfun in dist_funs) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
plot_hist <- function(counts, title = "Histogram") { | |
fdf <- as.data.frame(table(counts)) | |
pl <- (ggplot(fdf,aes(x=counts,y=Freq,ymin=0,ymax=Freq)) | |
+ geom_bar(colour="white",fill="blue",stat="identity") | |
+ ggtitle(title) | |
+ theme(plot.title=element_text(family="Arial", size=10)) | |
+ theme(axis.text.x = element_text(angle = 90, hjust = 1)) |