Module:Interval extension: Difference between revisions

R-4981 (talk | contribs)
Created page with "local p = {} -- Calculated by http://www.mikebattagliamusic.com/HE-JS/HE.html. -- Note: that the unit is Nat, not Bit. local lookup_table = { 2.4653643754704344,2.469526..."
 
ArrowHead294 (talk | contribs)
mNo edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
local p = {}
local p = {}


-- Calculated by http:
local


-- Get from the table with Linear Interpolation
-- Get from the table with Linear Interpolation
function p.harmonic_entropy_with_lookup_table(c)
function p.harmonic_entropy_with_lookup_table(c)
     if c <= 0 then c = -c end
     if c < 0 then c = -c end
    if c == 0 then return 2.4653643754704344 end
     if c >= #lookup_table then return 4.805772050182217 end
     if c >= #lookup_table then return 4.805772050182217 end
     if c == math.floor(c) then return lookup_table[math.floor(c)] end
     if c == math.floor(c) then return lookup_table[math.floor(c)] end


     b = c - math.floor(c)
     b = c - math.floor(c)
     return lookup_table[math.floor(c)] * (1-b) + lookup_table[math.floor(c) + 1] * b
     return lookup_table[math.floor(c)] * (1 - b) + lookup_table[math.floor(c) + 1] * b
end
end


return p
return p