Godtone (talk | contribs)
m My Python 3 code: generalize
Godtone (talk | contribs)
m comment correction and remove potentially confusing aliases (at least pending a rework, cuz arguably the complexity weighting should happen before the error squaring step)
Line 1,307: Line 1,307:
def et_badness(ivs,v,badness=lambda rel_err,x,et2: rel_err**2 * et2**2,weighting=lambda x: iv_complexity(x),combine='avg',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',et2=0):
# if the weighting is unspecified, use the default of:
# if the weighting is unspecified, use the default of:
# weighting an interval x proportional to its odd-limit complexity iv_complexity(x);
# weighting an interval x's (by default squared) error contribution proportional to its odd-limit complexity (iv_complexity(x));
# this is a compromise between theoretic sensitivity (approx. equal to the square of the odd-limit complexity)
# this is a compromise between theoretic sensitivity (approx. equal to the square of the odd-limit complexity)
# and not underweighting simpler intervals and accounting for that more complex intervals will tend to be used
# and not underweighting simpler intervals and accounting for that more complex intervals will tend to be used
# in a harmonic/chordal context which justifies their otherwise-higher effective felt error through templating
# in a harmonic/chordal context which justifies their otherwise-higher effective felt error through templating
if weighting==1 or weighting in ['unweighted','trivial','basic','CE','CEE']:
if weighting==1 or weighting in ['unweighted','trivial','basic']:
weighting = lambda x: 1 # for use with prime harmonic interval sets
weighting = lambda x: 1
elif weighting==2 or weighting in ['natural', 'harmonic', 'TE', 'te', 'tenney']:
elif weighting=='sensitive':
weighting = lambda x: 1/math.log2(x[0] * x[1]) # mainly for use with prime harmonic interval sets
weighting = lambda x: iv_complexity(x)**2
global ivs_cache
global ivs_cache
global ivs_int_cache
global ivs_int_cache