dwinter / dfe

Fitting, simulating and generally exploring the distribution of fitness effects from MA studies
0 stars 0 forks source link

N-G integral is divergent for some simulated values #3

Closed dwinter closed 9 years ago

dwinter commented 9 years ago

At present, some fitness values, including those simulated with our rma_gamma function, break they density function. There doesn't seem to be any rhyme or reason to which fitness values do this, but they occur most often when the mean effect of mutations islarge, and the mutation rate is low:

dma_gamma(B=13, Ut=1.3, a=2, log=TRUE, Ve=1e-4, w=0.889)
dma_gamma(B=13, Ut=1.3, a=2, log=TRUE, Ve=1e-4, w=0.888)
dma_gamma(B=13, Ut=1.3, a=2, log=TRUE, Ve=1e-4, w=0.890)

One work around, as demonstrated above, might be to catch these errors and take values very-slightly either side of the error-producing one. This likely relates to the errors we want to catch in #2 .

dwinter commented 9 years ago

Digging a little deeper on this, I can at least find the value that kills it

dfe:::NG_convolution(Beta=13, Ve=1e-4, a=2, k=15, z=0.889)

There is a bit of a spike in the function near this fitness value, taking values to the left and the right:

sapply(seq(0.885, 0.888, 0.001), dfe:::NG_convolution, Beta=13, Ve=1e-4, a=2, k=15)   
sapply(seq(0.890, 0.895, 0.001), dfe:::NG_convolution, Beta=13, Ve=1e-4, a=2, k=15)
dwinter commented 9 years ago

This bug is closed since moving to GSL for integration