shifted with the logsumexp trick for stability
proof:
Dec 22, 20241 min read
logsumexp(x1,x2,…,xn)=log(∑i=1nexi)
shifted with the logsumexp trick for stability
logsumexp(x1,x2,…,xn)=maxixi+log(∑i=1nexi−maxjxj)
proof:
log(i=1∑nexi) log(i=1∑nexi)=log(i=1∑nexi−M⋅eM) =log(eMi=1∑nexi−M) =log(eM)+log(i=1∑nexi−M) =M+log(i=1∑nexi−M) log(i=1∑nexi)=imaxxi+log(i=1∑nexi−maxjxj)