From 16c48d9cacccad78e040258ceff9634b1d79f88f Mon Sep 17 00:00:00 2001 From: PharmCat Date: Sun, 8 Aug 2021 13:40:22 +0300 Subject: [PATCH] statutils --- Project.toml | 2 +- src/types.jl | 2 +- src/utils.jl | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index db4d3d1..ae2a57d 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "MetidaBase" uuid = "075456b7-4006-432f-9324-2f8453996c49" authors = ["PharmCat and contributors"] -version = "0.3.1" +version = "0.3.2" [deps] #StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" diff --git a/src/types.jl b/src/types.jl index c28748d..0ab1087 100644 --- a/src/types.jl +++ b/src/types.jl @@ -220,7 +220,7 @@ end function subset(d::DataSet, sort::Dict) inds = findall(x-> sort ⊆ x.id, d.ds) if length(inds) > 0 return DataSet(d.ds[inds]) end - nothing + [] end ################################################################################ # metida_table from DataSet{AbstractIDResult} diff --git a/src/utils.jl b/src/utils.jl index 504397c..b5eb963 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -19,3 +19,42 @@ end isnanormissing(x::Number) = isnan(x) isnanormissing(x::Missing) = true + + +# STATISTICS + + +#CV2se +""" + sdfromcv(cv::Real)::AbstractFloat + +LnSD from CV. +""" +function sdfromcv(cv) + return sqrt(varfromcv(cv)) +end +""" + varfromcv(cv::Real)::AbstractFloat + +LnVariance from CV. +""" +function varfromcv(cv) + return log(1+cv^2) +end +""" + cvfromvar(σ²::Real)::AbstractFloat + +CV from variance. +""" +function cvfromvar(σ²) + return sqrt(exp(σ²)-1) +end +#CV2se +""" + cvfromsd(σ::Real)::AbstractFloat + +CV from variance. +""" +function cvfromsd(σ) + return sqrt(exp(σ^2)-1) +end