community-simulator icon indicating copy to clipboard operation
community-simulator copied to clipboard

Sampling too few cells (by 1) in the passage function.

Open jccvila opened this issue 4 years ago • 0 comments

Line 309 of init.py.

N[:,k] += np.random.multinomial(int(scale*N_tot[j]*f[k,j]),(self.N/N_tot).values[:,j])*1./scale  

should probably be

N[:,k] += np.random.multinomial(round(scale*N_tot[j]*f[k,j]),(self.N/N_tot).values[:,j])*1./scale  

Int convert a float to an integer by truncating the decimal part which means that you will often end up sampling 1 fewer cell than expected. For example if scale*N_tot[j]*f[k,j] is 0.99, you will transfer 0 cells.

I think, but am not 100% sure that the best practice would be for the number of cells transferred to follow a Poisson distribution.

np.random.multinomial(np.random.poisson(scale*N_tot[j]*f[k,j]),(self.N/N_tot).values[:,j])*1./scale  

jccvila avatar Apr 30 '20 14:04 jccvila