Module:Harmonic entropy: Difference between revisions

Sintel (talk | contribs)
merge changes from dev
ArrowHead294 (talk | contribs)
Remove already finished Todo
 
(11 intermediate revisions by 2 users not shown)
Line 1: Line 1:
-- TODO: this module should just be called harmonic entropy!
local limits = require("Module:Limits")
local limits = require("Module:Limits")
local rat = require("Module:Rational")
local rat = require("Module:Rational")
local p = {}
local p = {}


-- compute harmonic Shannon entropy for an interval of `c` cents
-- Compute Harmonic Shannon entropy for an interval of `c` cents
-- `c`, `deviation`: in cents
-- `c`, `deviation`: in cents
-- `ratios`: an array of rational numbers
-- `ratios`: an array of rational numbers
Line 12: Line 11:
return math.sqrt(rat.benedetti_height(ratio))
return math.sqrt(rat.benedetti_height(ratio))
end
end
deviation = deviation or 17
deviation = deviation or 1200 * math.log(1.01, 2)
ratios = ratios
ratios = ratios
or limits.integer_limit(200, function(ratio)
or limits.integer_limit(200, function(ratio)