Distribute a fixed number of events to the days of a year following a specific distribution I am trying to distribute a given (fixed) number of events of a year over the respective year. The empirical distribution can be modelled with a Poisson distribution because there are usually only between 1 and 14 events per day.
I tried looping through the days of the year and generating a random number of events from a poisson distribution. The point at which I struggle is to distribute ALL events. If I overestimate the distribution, there are no events at all at the last weeks of the year and if I underestimate the distribution, there are several events left but they all need to take place in the considered year.
Is there any way to distribute all events?
Thanks a lot for your help and inspirations!
 A: The conditional distribution of a collection of independent Poisson variates, given their total, $n$, is a multinomial distribution with $p$-parameters proportional to the corresponding Poisson rates. That is, $p_i = \lambda_i/\lambda_\text{total},\: i=1,2,...,k$, where $\lambda_\text{total}=\sum_i \lambda_i$.
An easy way to randomly allocate them is discussed in the "unequal" case here How to sample n
observations from a multinomial distribution using binomial (or poisson) sampling?. Essentially you generate one value, then given that value, compute the conditional multinomial distribution of the remainder given what has already been generated, progressing through all the values and updating the conditional distribution for the remaining "cells" at each step; whatever is left at the last cell is the count value for that cell.
A: If I understand correctly, you have, say, N = 365 * 7 = 2555 events to distribute across each day of the year in such way that each day has a number of events given by a Poisson with, in this case, $\lambda = 7$.
For a simulation, you could assign to each of the 365 days a weight given by a random draw from the desired distribution, e.g. $Poisson(\lambda = 7)$, or any distribution really. Then distribute the events accordingly. Here's the code R:
smart.round <- function(x) {
  # Round vector x while keeping the sum of the rounded output the same as
  # input. Credit: https://stackoverflow.com/a/32544987/1114453
  y <- floor(x)
  indices <- tail(order(x-y), round(sum(x)) - sum(y))
  y[indices] <- y[indices] + 1
  y
}

N <- 365 * 7

pp <- rpois(n= 365, lambda= 7)
pp <- pp/sum(pp)

# Distribute events. Make final sum equals N after rounding
year <- smart.round(pp * N)

hist(year, xlab= 'N events', ylab= 'N days')


