Module:JI ratio finder: Difference between revisions
m Fixed error calculation; error should be how far the target cent value is from the JI ratio's cent value |
m Clarified int limit for candidate ratio search (it's a denominator limit, not an int limit) |
||
| Line 24: | Line 24: | ||
end | end | ||
-- Finds candidate ratios up to a cent value and up to an integer limit | -- Finds candidate ratios up to a cent value and up to an integer limit that | ||
-- Ratios found this way will range from 0 cents to the given cent value | -- applies to the denominator only. | ||
-- These ratios should then be filtered as needed | -- Ratios found this way will range from 0 cents to the given cent value. | ||
function p.find_candidate_ratios(cents, | -- These ratios should then be filtered as needed. | ||
function p.find_candidate_ratios(cents, denominator_limit) | |||
local cents = cents or 1200 | local cents = cents or 1200 | ||
local | local denominator_limit = denominator_limit or 99 | ||
local candidate_ratios = {} | local candidate_ratios = {} | ||
for i = 1, | for i = 1, denominator_limit do | ||
local denominator = i | local denominator = i | ||
local numerator = i | local numerator = i | ||
| Line 160: | Line 161: | ||
end | end | ||
-- Finds approximated JI ratios for a cent value for a prime and | -- Finds approximated JI ratios for a cent value for a prime and denominator limit | ||
-- Meant to find ratios within the range of a single cent value | -- Meant to find ratios within the range of a single cent value | ||
-- TODO: use integer limit instead of odd limit | -- TODO: use integer limit instead of odd limit | ||