Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,14 @@
|
|||
arithmeticMean <- function(a, b) { (a + b)/2 }
|
||||
geometricMean <- function(a, b) { sqrt(a * b) }
|
||||
|
||||
arithmeticGeometricMean <- function(a, b) {
|
||||
rel_error <- abs(a - b) / pmax(a, b)
|
||||
if (all(rel_error < .Machine$double.eps, na.rm=TRUE)) {
|
||||
agm <- a
|
||||
return(data.frame(agm, rel_error));
|
||||
}
|
||||
Recall(arithmeticMean(a, b), geometricMean(a, b))
|
||||
}
|
||||
|
||||
agm <- arithmeticGeometricMean(1, 1/sqrt(2))
|
||||
print(format(agm, digits=16))
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
a <- c(1, 1, 1)
|
||||
b <- c(1/sqrt(2), 1/sqrt(3), 1/2)
|
||||
agm <- arithmeticGeometricMean(a, b)
|
||||
print(format(agm, digits=16))
|
||||
Loading…
Add table
Add a link
Reference in a new issue