Thank you, Dahua, for your suggestion. I will definitely take a look in this package! :)
Best, Charles On Mon, Jun 23, 2014 at 4:35 PM, Dahua Lin <[email protected]> wrote: > Hi, Charles, > > Looks like you are doing sampling based on given/computed probabilities. > > You might want to checkout the sampling facilities provided in StatsBase > (see http://statsbasejl.readthedocs.org/en/latest/sampling.html for > details). > > That package provides a series of optimized sampling algorithms, which may > probably make your program even faster (than calling cumsum). > > Dahua > > > > On Friday, June 20, 2014 10:15:55 AM UTC-5, Charles Santana wrote: > >> Dear Julia users, >> >> First of all, Congratulations for this amazing community and for this >> impressive language! I used to program in C++ and in R, I started to >> program with Julia 3 months ago and it has changed my life for better!! >> Thank you!! >> >> By checking the profile of a program we are developing we noted that the >> "bottleneck" seems to be in a cumulative sum along a dimension in a matrix, >> for what we use the function cumsum. >> >> We are doing something like this: >> >> DI = rand(5,5); >> Dc = cumsum(DI,2); >> >> Just to try to clarify what we are doing: Imagine that Matrix DI(i,j) >> represents the probability of an individual to move from a site i to a site >> j. We use Dc to determine to which site an individual in site i will move, >> by generating a random number between 0 and maximum(Dc[i,:]). That means, >> we are trying to perform a Multinomial Distribution. >> >> Do you know an alternative to cumsum or do you indicate a good way to use >> this function. >> >> Thanks in advance for any help! >> >> Best regards, >> >> Charles Novaes de Santana >> -- >> Um axé! :) >> >> -- >> Charles Novaes de Santana, PhD >> http://www.imedea.uib-csic.es/~charles >> > -- Um axé! :) -- Charles Novaes de Santana, PhD http://www.imedea.uib-csic.es/~charles
