Skip to content

Commit

Permalink
notes
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanbeaudette committed Feb 3, 2025
1 parent 467bc2a commit 66cb2a3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions R/accuracy_uncertainty.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
## TODO: test that sum(x) == 1
shannonEntropy <- function(x, b = 2) {
# 0s automatically removed by na.rm=TRUE (0 * log(0) = Nan)
# consider: ifelse(x == 0, 0, x * log(x))

res <- -1 * sum(x * log(x, base = b), na.rm = TRUE)
return(res)
}
Expand Down
6 changes: 5 additions & 1 deletion misc/sandbox/soil-texture-separate-sim-by-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ data("soiltexture", package = 'aqp')
## get all soil texture measurements from latest KSSL snapshot

# connect
db <- dbConnect(RSQLite::SQLite(), 'E:/NASIS-KSSL-LDM/ncss_labdata.sqlite')
db <- dbConnect(RSQLite::SQLite(), 'E:/NASIS-KSSL-LDM/ncss_labdata-2023.sqlite')

qq <- "
SELECT
Expand Down Expand Up @@ -124,8 +124,12 @@ prepareCompositionalSummary <- function(i, var = 'class') {
}


## TODO: use rnorm.acomp()


##
##
##
sampleComposition <- function(i, var = 'class', n = 100) {
# simulate from Dirichlet
s <- rDirichlet.acomp(n, i$D.alpha)
Expand Down

0 comments on commit 66cb2a3

Please # to comment.