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
# v vector input | |
# relfreq output data.frame of frquency and relative frequency | |
relfreq <- function(v){ | |
tab.v <- table(v) | |
result <- cbind(data.frame(tab.v), rel=tab.v/length(v)) | |
result[,4] <- format(round(result[,4]*100, 2), nsmall = 2) | |
names(result) <- c("var","freq",NA,"relfreq") | |
return(result[order(-result$freq),c(1,2,4)]) | |
} |
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
#returning vector without extreme/outlier values | |
rm.extreme <- function(v) { | |
q3<-quantile(v, .75) | |
q1<-quantile(v, .25) | |
iqr <- 1.5 * ( q3- q1) | |
sapply(v, function(x) { | |
x[x > (q1 - iqr) & x < (q3 + iqr)] | |
}) | |
} |
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
ab.result <- function(control_success, control_failed, variant_success, variant_failed){ | |
growth <- (variant_success/(variant_success+variant_failed))/(control_success/(control_success+control_failed))-1 | |
control_success <- control_success+1 | |
control_failed <- control_failed+1 | |
variant_success <- variant_success+1 | |
variant_failed <- variant_failed+1 | |
winning_prob <- 0 | |
for(i in 0:(variant_success-1)){ | |
winning_prob <- winning_prob + exp(lbeta(control_success+i, variant_failed+control_failed) | |
- log(variant_failed+i) - lbeta(1+i, variant_failed) - lbeta(control_success, control_failed)) |
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
function getCol(data, colname) { | |
var x = []; | |
for (var i = 0; i < data.length; i++) { | |
x.push(data[i][colname]); | |
} | |
return x; | |
} | |
function xy(data, x_col, y_col) { | |
return { |
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
//md5 function | |
!function(n){"use strict";function t(n,t){var r=(65535&n)+(65535&t),e=(n>>16)+(t>>16)+(r>>16);return e<<16|65535&r}function r(n,t){return n<<t|n>>>32-t}function e(n,e,o,u,c,f){return t(r(t(t(e,n),t(u,f)),c),o)}function o(n,t,r,o,u,c,f){return e(t&r|~t&o,n,t,u,c,f)}function u(n,t,r,o,u,c,f){return e(t&o|r&~o,n,t,u,c,f)}function c(n,t,r,o,u,c,f){return e(t^r^o,n,t,u,c,f)}function f(n,t,r,o,u,c,f){return e(r^(t|~o),n,t,u,c,f)}function i(n,r){n[r>>5]|=128<<r%32,n[(r+64>>>9<<4)+14]=r;var e,i,a,h,d,l=1732584193,g=-271733879,v=-1732584194,m=271733878;for(e=0;e<n.length;e+=16)i=l,a=g,h=v,d=m,l=o(l,g,v,m,n[e],7,-680876936),m=o(m,l,g,v,n[e+1],12,-389564586),v=o(v,m,l,g,n[e+2],17,606105819),g=o(g,v,m,l,n[e+3],22,-1044525330),l=o(l,g,v,m,n[e+4],7,-176418897),m=o(m,l,g,v,n[e+5],12,1200080426),v=o(v,m,l,g,n[e+6],17,-1473231341),g=o(g,v,m,l,n[e+7],22,-45705983),l=o(l,g,v,m,n[e+8],7,1770035416),m=o(m,l,g,v,n[e+9],12,-1958414417),v=o(v,m,l,g,n[e+10],17,-42063),g=o(g,v,m,l,n[e+11],22,-1990404162),l=o(l,g,v,m,n[e |