Skip to content

Commit

Permalink
tidied up beta0 function, more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pboesu committed Dec 30, 2017
1 parent d1271da commit cfb0369
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 6 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by roxygen2: do not edit by hand

export(beta0)
export(dget_tb)
export(get_lb)
export(get_tb)
Expand Down
19 changes: 13 additions & 6 deletions R/beta0.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
## beta0
# particular incomplete beta function

##
#function f =

#' particular incomplete beta function
#'
#' \deqn{B_x1(4/3,0) - B_x0(4/3,0) = \int_x0^x1 t^(4/3-1) (1-t)^(-1) dt}{B_x1(4/3,0) - B_x0(4/3,0) = int_x0^x1 t^(4/3-1) (1-t)^(-1) dt}
#'
#' @param x0 scalar with lower boundary for integration
#' @param x1 scalar with upper boundary for integration
#'
#' @return scalar with particular incomple beta function
#' @export
#'
#' @examples
#' beta0(0.1, 0.2)
#'
beta0 = function(x0,x1){
# created 2000/08/16 by Bas Kooijman; modified 2011/04/10

Expand Down
10 changes: 10 additions & 0 deletions inst/MATLAB/DEBtool_examples.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
%DEBtool_M calculations that are used in the DEButilities R package to
%check for numerical equivalence of function outputs

%get_ue0 example
g = 6; k = 6; kap = .8; uHb = .001; vHb = uHb/ (1 - kap);
pars = [g, k, vHb];
[uE0, lb, info] = get_ue0(pars);

%beta0 example
betazero = beta0(0.1,0.2);
23 changes: 23 additions & 0 deletions man/beta0.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions tests/testthat/test_MATLAB_numerical_equivalence.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,12 @@ test_that("get_tb matches DEBtool", {
expect_equal(get_tb(c(.1,.5,.03)), c(8.6038, 0.2658, 1), tolerance = 0.001)
})

test_that("beta0 matches DEBtool_M", {
expect_equal(beta0(0.1, 0.2), 0.062455351015153)
})

test_that("get_ue0 matches DEBtool_M", {
g = 6; k = 6; kap = .8; uHb = .001; vHb = uHb/ (1 - kap);
pars = c(g, k, vHb);
expect_equal(get_ue0(pars), c(0.008171217468332, 0.188067711870661, 1))
})

0 comments on commit cfb0369

Please sign in to comment.