Godtone (talk | contribs)
Godtone (talk | contribs)
m →My Python 3 code: as the badness function is undefined, although the names are intuitive, it's much more practical to directly specify the weighting.
 
Line 1,341: Line 1,341:
#            strict_optimal_edo_sequence is unaffected however.
#            strict_optimal_edo_sequence is unaffected however.
def et_badness(ivs,v,badness=lambda rel_err,x,et2: rel_err**2 * et2**2,weighting=lambda x: iv_complexity(x),combine='avg',mapping=True,et2=0):
def et_badness(ivs,v,badness=lambda rel_err,x,et2: rel_err**2 * et2**2,weighting=lambda x: iv_complexity(x),combine='avg',mapping=True,et2=0):
# if the weighting is unspecified, use the default of:
# weighting=2 is recommended for MSE so that we weight intervals proportional to their odd-limit complexity.
# weighting an interval x's (by default squared) error contribution proportional to its odd-limit complexity (iv_complexity(x));
# by contrast, the default, weighting=1, is perhaps the only weighting that makes maximal sense generally (w/ badness unspecified).
# this is a compromise between theoretic sensitivity (approx. equal to the square of the odd-limit complexity)
# if you feel some EDOs are missing, try half-integer weightings, tweaking badness, changing combine and even setting mapping=False.
# and not underweighting simpler intervals and accounting for that more complex intervals will tend to be used
# (or simply adjusting the set of intervals you wish to approximate.)
# in a harmonic/chordal context which justifies their otherwise-higher effective felt error through templating
if type(weighting)==str:
if weighting in [None,'none','unweighted','trivial','basic','constant']:
weighting = 0
elif weighting in ['','default','proportional']:
weighting = 1
elif weighting in ['sensitive','dyadic']:
weighting = 2
elif weighting=='simple':
weighting = -0.5 # as we may square after when doing a MSE, we use the square root
if type(weighting) in [int,float]:
if type(weighting) in [int,float]:
weighting = lambda x,w=weighting: iv_complexity(x)**w
weighting = lambda x,w=weighting: iv_complexity(x)**w