plogp: Calculate the product of a probability and its base-2...

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/r-utility-plogp.R

Description

This function calculates the product of a probability value and its a base-2 logarithm, returning 0 for 0 probabilities. It is used in examples presented in the book Cichosz, P. (2015): Data Mining Algorithms: Explained Using R. See Appendix B or http://www.wiley.com/go/data_mining_algorithms for more details.

Usage

1
plogp(p)

Arguments

p

a non-negative value or vector of values

Details

This avoids the NaN result produced by 0*log2(0) by forcing the result to be 0 for zero probabilities.

Value

If p>0 then p*log2(p) and 0 otherwise.

Author(s)

Pawel Cichosz <p.cichosz@elka.pw.edu.pl>

See Also

logp

Examples

1
2
3
plogp(0)
plogp(1)
plogp(0.5)

42n4/dmr.util documentation built on May 20, 2019, 2:02 p.m.