Module:Infobox ET: Difference between revisions
No edit summary |
No edit summary |
||
| Line 203: | Line 203: | ||
end | end | ||
local | local harmonic_entropy_r = 0 | ||
local harmonic_entropy_min = 1000 | local harmonic_entropy_min = 1000 | ||
local harmonic_entropy_list = {} | local harmonic_entropy_list = {} | ||
for i=1, math.floor(et.size)-1 do | for i=1, math.floor(et.size)-1 do | ||
he = interval_extension.harmonic_entropy_with_lookup_table(step_size * i) | he = interval_extension.harmonic_entropy_with_lookup_table(step_size * i) | ||
harmonic_entropy_r = harmonic_entropy_r + he / (math.floor(et.size)-1) | |||
if he <= harmonic_entropy_min then harmonic_entropy_min = he end | if he <= harmonic_entropy_min then harmonic_entropy_min = he end | ||
table.insert(harmonic_entropy_list, he) | table.insert(harmonic_entropy_list, he) | ||
end | end | ||
table.sort(harmonic_entropy_list) | table.sort(harmonic_entropy_list) | ||
local harmonic_entropy_median = harmonic_entropy_list[math.floor((et.size-2)/2)] | local harmonic_entropy_median = harmonic_entropy_list[math.floor((et.size-2)/2)] | ||
if et.size == 3 then | if et.size == 3 then | ||
harmonic_entropy_median = | harmonic_entropy_median = harmonic_entropy_r | ||
end | end | ||
if et.size <= 2 then | if et.size <= 2 then | ||
| Line 226: | Line 225: | ||
table.insert(infobox_data, { | table.insert(infobox_data, { | ||
"Average of [[Harmonic entropy]] <br> (from [http://www.mikebattagliamusic.com/HE-JS/HE.html HE Calc])", | "Average of [[Harmonic entropy]] <br> (from [http://www.mikebattagliamusic.com/HE-JS/HE.html HE Calc])", | ||
"~" .. utils._round( | "~" .. utils._round(harmonic_entropy_r, 6) .. " nats" | ||
}) | }) | ||
table.insert(infobox_data, { | table.insert(infobox_data, { | ||
| Line 241: | Line 240: | ||
for i=1, math.floor(et.size)-2 do | for i=1, math.floor(et.size)-2 do | ||
for j=1, i-1 do | for j=1, i-1 do | ||
local delta = (rat.log(step_size | local delta = (rat.log(i * step_size / 1200) - rat.log(j * step_size / 1200)) / (rat.log(j * step_size / 1200) - 1) | ||
local he = interval_extension.harmonic_entropy_with_lookup_table(rat.cents(delta)) | local he = interval_extension.harmonic_entropy_with_lookup_table(rat.cents(delta)) | ||
if he <= delta_harmonic_entropy_min then delta_harmonic_entropy_min = he end | if he <= delta_harmonic_entropy_min then delta_harmonic_entropy_min = he end | ||