public static List<Long> binomialSequence(final double prob, final long max)
	{
		final List<Long> result = new ArrayList<Long>();
		if (prob > 0 && prob < 1.01 && max >= 0)
		{
			final Random random = new Random();
			final double logQ = Math.log(1 - prob);
			long current = -1;

			do
			{
				final double rnd = random.nextDouble();
				current += 1 + Math.floor(Math.log(1 - rnd) / logQ);
				if (current < max)
				{
					result.add(current);
				}
			}
			while (current < max);
		}
		return result;
	}