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(manipulate) | |
# Beta | |
x <- seq(0, 1, by=0.01) | |
manipulate( | |
{ ci <- qbeta(c(0.05, .5, 0.95), alpha, beta) | |
plot(x, dbeta(x, alpha, beta), | |
col="blue", lwd=2, type="l", las=1, bty="n", |
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
# use RStudio | |
library(manipulate) | |
lgrowth <- function(x, a, b, c) a/(1+exp(-(b+c*x))) | |
manipulate( | |
curve(lgrowth(x, a, b, c), -4, 4, ylim = c(-1, 2)), | |
a = slider(-2, 2, initial = 1, step = 0.01), | |
b = slider(-2, 2, initial = 0, step = 0.01), |
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
priors <- c(0, 0.001, 0.333, 0.5, 1) | |
s <- c(0, 1, 1, 5, 5) | |
f <- c(1, 1, 2, 1, 25) | |
dbeta2 <- function(x, prior1, prior2 = prior1) { |
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
ptmp <- par(mfrow=c(2,2), mar = c(3,3,3,3)) | |
set.seed(123) | |
n <- 7 | |
x <- rnorm(n, sd = 3) | |
K <- function(x) dnorm(x) |
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
set.seed(123) | |
N <- 1e5 | |
mu <- c(2,4,6) | |
sigma <- rep(0.5, 3) | |
lambda <- (1:3)/6 | |
dat <- c( |
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
set.seed(123) | |
x <- rnorm(7) | |
dx <- density(x) | |
plot(dx) | |
f <- approxfun(dx, yleft = 0, yright = 0) |
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(extraDistr) | |
bins <- function(x, n = 512L) { | |
x <- x[!is.na(x)] | |
h <- diff(range(x))/(n-4) | |
mids <- seq(min(x)-2*h, max(x)+2*h, length.out = n) | |
breaks <- c(mids[1L] - h, mids + h) | |
counts <- unname(tapply(x, cut(x, breaks), length, | |
default = 0L)) |
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
lst <- function(...) { | |
dots <- list(...) | |
call <- match.call() | |
names(dots) <- sapply(substitute(...()), as.character) | |
dots | |
} | |
funs <- lst(mode, typeof, class, is.atomic, is.array, is.vector, is.numeric, is.character, is.logical, is.matrix, is.data.frame, is.list) | |
tests <- lst( |
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
import numpy as np | |
from sklearn.base import BaseEstimator, ClassifierMixin | |
from sklearn.ensemble import IsolationForest | |
from sklearn.covariance import EllipticEnvelope | |
from sklearn.svm import OneClassSVM | |
def mode(x): | |
(values, counts) = np.unique(x, return_counts = True) |
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
#include <Rcpp.h> | |
using namespace Rcpp; | |
// [[Rcpp::export]] | |
List cpp_rle2( | |
const NumericVector& x, | |
const double h = 0, | |
const double eps = 1e-16 | |
) { |
OlderNewer