Fade-in/fade-out effect with exponential ramp


I am currently creating a 0.5s-long fade-in/fade-out of my visual stimulus by setting its opacity at each frame with a code component similar to this (linear ramp):

if t<0.5:
    stim_opacity = t/0.5
elif t>trial_dur-0.5 :
    stim_opacity = 1-((t-(trial_dur-0.5))/0.5)

However, I would like the opacity to increment/decrement slowly at first and more abruptly at the end of this 0.5s interval.
I was thinking something like an exponential ramp but I can’t figure out the formula for my code component. Would you know?

Thank you very much in advance :slight_smile: