In my code I am required to use a piecewise function within another defined function. But I am having some trouble attempting this. The code I have supplied obviously does not work but I structured it this way so you can see what I am going for.
def f(λ,a,u,o1,o2):
if (λ < u): return o = o1
else: return o = o2
return a*math.exp((λ-u)^2/(-2*o^2))
My main function is of λ, and the piecewise function is the o values. Where I want them to take different values when λ is greater and less than u.
I thought there would be something online for this but I can't seem to find anything that fits this specific example.
What I have tried:
An idea was to define the two functions (one for λ and the piecewise function) seperately. However, both of which rely on eachother so I figure they must be defined as one.
Another attempt I was convinced would work is;
def f(λ,a,u,o1,o2):
return a*math.exp((λ-u)^2/(-2*(if λ<μ then σ1 else σ2)^2))
This is where I am now ^