Please consider the statements below:
sum_value = fixed_value - current_value
,
where fixed_value
is a constant, and current_value
is a function of thresholds
;
thresholds
has two threshold_level
values: thresholds = [10, 20]
;
I need to find a rato of sim_value
corresponding to threshold_level = 10
to sim_value
corresponding to threshold_level = 20
, that is final_sim_value = sim_value_at_10/sim_value_at_20
.
The code part is
thresholds = [10, 20]
fixed_value = 100
for threshold_level in thresholds:
current_value = 5 - threshold_level
sim_value = fixed_value - current_value
def sim_value_multi(threshold_level):
if threshold_level == 10:
sim_value_at_10 = sim_value
return sim_value_at_10
if threshold_level == 20:
sim_value_at_20 = sim_value
return sim_value_at_20
final_sim_value = sim_value_multi(10)/sim_value_multi(20)
print('sim_value_multi(10) is ', sim_value_multi(10))
print('sim_value_multi(20) is ', sim_value_multi(20))
print('final_sim_value is ', final_sim_value)
print('--------------------')
final_sim_value = sim_value_multi(10)/sim_value_multi(20)
print('sim_value_multi(10) is ', sim_value_multi(10))
print('sim_value_multi(20) is ', sim_value_multi(20))
print('final_sim_value is ', final_sim_value)
which gives this output:
sim_value_multi(10) is 105
sim_value_multi(20) is 105
final_sim_value is 1.0
sim_value_multi(10) is 115
sim_value_multi(20) is 115
final_sim_value is 1.0
--------------------
sim_value_multi(10) is 115
sim_value_multi(20) is 115
final_sim_value is 1.0
Could you please correct me or suggest a proper solution?
CodePudding user response:
Are you trying to obtain this result ?
thresholds = [10, 20]
fixed_value = 100
current_values = []
for threshold_value in thresholds:
current_values.append(fixed_value threshold_value - 5)
print('sim_value_multi(10) is ', current_values[0])
print('sim_value_multi(20) is ', current_values[1])
print('final_sim_value is ', current_values[0]/current_values[1])
Output
sim_value_multi(10) is 105
sim_value_multi(20) is 115
final_sim_value is 0.9130434782608695