Adds additional adjustment formulas
This commit is contained in:
@ -68,12 +68,14 @@ class Copycat(object):
|
|||||||
def run(self, initial, modified, target, iterations):
|
def run(self, initial, modified, target, iterations):
|
||||||
self.workspace.resetWithStrings(initial, modified, target)
|
self.workspace.resetWithStrings(initial, modified, target)
|
||||||
|
|
||||||
#self.temperature.useAdj('original')
|
self.temperature.useAdj('original')
|
||||||
#self.temperature.useAdj('entropy')
|
#self.temperature.useAdj('entropy')
|
||||||
#self.temperature.useAdj('inverse') # 100 weight
|
#self.temperature.useAdj('inverse') # 100 weight
|
||||||
#self.temperature.useAdj('fifty_converge')
|
#self.temperature.useAdj('fifty_converge')
|
||||||
#self.temperature.useAdj('soft')
|
#self.temperature.useAdj('soft')
|
||||||
self.temperature.useAdj('weighted_soft')
|
#self.temperature.useAdj('weighted_soft')
|
||||||
|
#self.temperature.useAdj('alt_fifty')
|
||||||
|
#self.temperature.useAdj('average_alt')
|
||||||
|
|
||||||
answers = {}
|
answers = {}
|
||||||
for i in range(iterations):
|
for i in range(iterations):
|
||||||
|
|||||||
@ -24,31 +24,38 @@ def _entropy(temp, prob):
|
|||||||
f = (c + 1) * prob
|
f = (c + 1) * prob
|
||||||
return -f * math.log2(f)
|
return -f * math.log2(f)
|
||||||
|
|
||||||
|
def _weighted(temp, prob, s, u):
|
||||||
|
weighted = (temp / 100) * s + ((100 - temp) / 100) * u
|
||||||
|
return weighted
|
||||||
|
|
||||||
def _weighted_inverse(temp, prob):
|
def _weighted_inverse(temp, prob):
|
||||||
iprob = 1 - prob
|
iprob = 1 - prob
|
||||||
weight = 100
|
return _weighted(temp, prob, iprob, prob)
|
||||||
inverse_weighted = (temp / weight) * iprob + ((weight - temp) / weight) * prob
|
|
||||||
return inverse_weighted
|
|
||||||
|
|
||||||
def _fifty_converge(temp, prob): # Uses .5 instead of 1-prob
|
def _fifty_converge(temp, prob): # Uses .5 instead of 1-prob
|
||||||
weight = 100
|
return _weighted(temp, prob, .5, prob)
|
||||||
curved = (temp / weight) * .5 + ((weight - temp) / weight) * prob
|
|
||||||
return curved
|
|
||||||
|
|
||||||
def _soft_curve(temp, prob): # Curves to the average of the (1-p) and .5
|
def _soft_curve(temp, prob): # Curves to the average of the (1-p) and .5
|
||||||
iprob = 1 - prob
|
return min(1, _weighted(temp, prob, (1.5-prob)/2, prob))
|
||||||
weight = 100
|
|
||||||
curved = min(1, (temp / weight) * ((1.5 - prob) / 2) + ((weight - temp) / weight) * prob)
|
|
||||||
return curved
|
|
||||||
|
|
||||||
def _weighted_soft_curve(temp, prob): # Curves to the weighted average of the (1-p) and .5
|
def _weighted_soft_curve(temp, prob): # Curves to the weighted average of the (1-p) and .5
|
||||||
weight = 100 # Don't change me in this context
|
weight = 100
|
||||||
gamma = .5 # convergance value
|
gamma = .5 # convergance value
|
||||||
alpha = 1 # gamma weight
|
alpha = 1 # gamma weight
|
||||||
beta = 3 # iprob weight
|
beta = 3 # iprob weight
|
||||||
curved = min(1, (temp / weight) * ((alpha * gamma + beta * (1 - prob)) / (alpha + beta)) + ((weight - temp) / weight) * prob)
|
curved = min(1, (temp / weight) * ((alpha * gamma + beta * (1 - prob)) / (alpha + beta)) + ((weight - temp) / weight) * prob)
|
||||||
return curved
|
return curved
|
||||||
|
|
||||||
|
def _alt_fifty(temp, prob):
|
||||||
|
s = .5
|
||||||
|
u = prob ** 2 if prob < .5 else math.sqrt(prob)
|
||||||
|
return _weighted(temp, prob, s, u)
|
||||||
|
|
||||||
|
def _averaged_alt(temp, prob):
|
||||||
|
s = (1.5 - prob)/2
|
||||||
|
u = prob ** 2 if prob < .5 else math.sqrt(prob)
|
||||||
|
return _weighted(temp, prob, s, u)
|
||||||
|
|
||||||
class Temperature(object):
|
class Temperature(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.reset()
|
self.reset()
|
||||||
@ -59,7 +66,9 @@ class Temperature(object):
|
|||||||
'inverse' : _weighted_inverse,
|
'inverse' : _weighted_inverse,
|
||||||
'fifty_converge' : _fifty_converge,
|
'fifty_converge' : _fifty_converge,
|
||||||
'soft' : _soft_curve,
|
'soft' : _soft_curve,
|
||||||
'weighted_soft' : _weighted_soft_curve}
|
'weighted_soft' : _weighted_soft_curve,
|
||||||
|
'alt_fifty' : _alt_fifty,
|
||||||
|
'average_alt' : _averaged_alt}
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
self.actual_value = 100.0
|
self.actual_value = 100.0
|
||||||
|
|||||||
Reference in New Issue
Block a user