This function computes the Dice similarity coefficient for two vectors,
either using a soft binary threshold (non-zero = 1), or by thresholding
values by quantile.
dice_overlap_soft_vector(x, y, quantile = 0.5)
Arguments
- x
Numeric vector.
- y
Numeric vector of the same length as `x`.
- quantile
Numeric between 0 and 1. If > 0, values below the given quantile
(based on absolute value) are set to 0 before computing Dice.
Value
Dice similarity coefficient (between 0 and 1).
Examples
dice_overlap_soft_vector(c(0,1,0,2), c(3,1,0,0)) # returns 0.5
#> [1] 0.5
dice_overlap_soft_vector(c(0,0,0,0), c(0,0,0,0)) # returns 1
#> [1] 1
dice_overlap_soft_vector(c(1,2,3,4), c(1,0,0,4), quantile=0.5) # uses threshold
#> [1] 0.5