import math def sigmoid(x: float) -> float: if x >= 0: return 1.0 / (1.0 + math.exp(-x)) exp_x = math.exp(x) return exp_x / (1.0 + exp_x) def softmax(values: list[float]) -> list[float]: if not values: return [] max_v = max(values) exps = [math.exp(v - max_v) for v in values] total = sum(exps) if total <= 0: return [1.0 / len(values)] * len(values) return [e / total for e in exps]