from math import exp
z = [2, 4, 1]
z2 = exp(z[0])
z2
z4 = exp(z[1])
z4
z1 = exp(z[2])
z1
denominator = z2 + z4 + z1
denominator
softmax_z2 = z2/denominator
softmax_z2
softmax_z4 = z4/denominator
softmax_z4
softmax_z1 = z1/denominator
softmax_z1
probability_distribution = softmax_z2 + softmax_z4 + softmax_z1
probability_distribution