import numpy as np def line(x, m, c): return m*x + c def inverse_line(x, m, c): return (x-c)/m def exponential_function(x, a, b, c): return (a-c)*np.exp(-x/b)+c def upper_boltzmann(x, f_max, k, x_zero): return f_max * np.clip((2 / (1+np.power(np.e, -k*(x - x_zero)))) - 1, 0, None) def full_boltzmann(x, f_max, f_min, k, x_zero): return (f_max-f_min) * (1 / (1 + np.power(np.e, -k * (x - x_zero)))) + f_min def full_boltzmann_straight_slope(f_max, f_min, k, x_zero=0): return (f_max-f_min)*k*1/2 def derivative_full_boltzmann(x, f_max, f_min, k, x_zero): return (f_max - f_min) * k * np.power(np.e, -k * (x - x_zero)) / (1 + np.power(np.e, -k * (x - x_zero))**2) def inverse_full_boltzmann(x, f_max, f_min, k, x_zero): if x < f_min or x > f_max: raise ValueError("Value undefined in inverse_full_boltzmann") return -(np.log((f_max-f_min) / (x - f_min) - 1) / k) + x_zero def clipped_line(x, a, b): return np.clip(a+b*x, 0, None) def inverse_clipped_line(x, a, b): if clipped_line(x, a, b) == 0: raise ValueError("Value undefined in inverse_clipped_line.") return (x-a)/b