math - Numerical problems of computing exponential numbers (from Gaussian PDFs) -


i have list of small exponential values (for example exp(n), n<-300), generated gaussian pdfs.

i want compute how each of them proportional sum, example following python-like pseudo-code does:

s = 0  # sum of values n in exponents:     s += exp(n)  n in exponents:     k = exp(n)/s  # want compute k each n 

the problem is, since values of n small, summation s turns out 0 sometimes, , i'll division-by-zero error.

i know 1 thing can add constant value (say 300) n prevent underflow, it'll cause overflow in other cases.

how can solve this?

i don't know whether i've expressed myself clearly, if of these doesn't make sense or grammar mistakes, please correct me. in advance.

as observed, can subtracting constant value m n.

to avoid overflow, not choose fixed m, such m = - 300. instead, choose m maximum of n. every normalized exponential value @ 1, hence normalized sum @ number of exponents, should reasonably small.


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -