public int sample(double[] prob, int[] probs_ids)
	{
		int i=0;
		int indSample=0;
		boolean found=false;
		double rand=random.nextDouble();
		while(i<prob.length && !found)
		{
			rand=rand-prob[probs_ids[i]];
			if(rand<0)
			{
				indSample=probs_ids[i];
				found=true;
			}
			i++;
		}
		return indSample;
	}