-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathR_Functions.r
More file actions
25 lines (24 loc) · 960 Bytes
/
R_Functions.r
File metadata and controls
25 lines (24 loc) · 960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Information-subAuthor ---------------------------------------------------
##########################################################################
# AUTHOR: David Geeraerts
# EMAIL: geeraerd@evergreen.edu
# LOCATION: Olympia, Washington U.S.A.
# TITLE: Kraken-R Functions
# Version: 29
# Purpose: Monolithic (Kraken-R) functions
#
# Copyright License: Creative Commons: Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0)
# http://creativecommons.org/licenses/by-nc-sa/3.0/
#
# Getting an ideal sample size
library('gtools')
SampleSize = function(a,d) { -log(d/2)/(2*a^2) }
sig = function(a,n) { pbinom(floor(n*0.5)-floor(n*a),size=floor(n),prob=0.5) }
binomsize = function(a,d) {
r=c(1,2*estimate(a,d))
v=binsearch(function(n) {sig(a,n) - d},range=r,lower=min(r),upper=max(r))
v$where[[length(v$where)]] }
# Name private functions with a "."
#create a resample function
.resample = function(x, ...) x[sample(length(x), ...)]
#