public SpikeCollection getRandom(int numberOfRandomSpikesToAnalyse) {

		SpikeCollection randomSpikes = new SpikeCollection();

		RandomDataImpl generator = new RandomDataImpl();

		// find total number of spikes
		int total = 0;
		for (SingleASspikes asSpikes : allUpdates.values()) {
			total = total + asSpikes.getNumberOfSpikes();
		}

		// check if I have enough spikes
		if (numberOfRandomSpikesToAnalyse > total) {
			numberOfRandomSpikesToAnalyse = total;
		}

		// get needed number of random spikes
		int selected = 0;
		ArrayList<MonitoredAS> monitoredASs = new ArrayList<MonitoredAS>(
				allUpdates.keySet());

		while (selected < numberOfRandomSpikesToAnalyse) {
			// get random key
			MonitoredAS as;
			if (monitoredASs.size() > 1) {
				as = monitoredASs.get(generator.nextInt(0,
						monitoredASs.size() - 1));
			} else {
				as = monitoredASs.get(0);
			}

			// get random spike
			SingleASspikes oneASspikes = allUpdates.get(as);
			// ArrayList<Long> seconds = new
			// ArrayList<Long>(oneASspikes.keySet());

			long time;
			long minTime = oneASspikes.getCurrentMinTime();
			long maxTime = oneASspikes.getCurrentMaxTime();
			if (minTime < maxTime) {
				time = generator.nextLong(oneASspikes.getCurrentMinTime(),
						oneASspikes.getCurrentMaxTime());
			} else {
				time = minTime;
			}

			if (oneASspikes.hasSpikeAtTime(time)) {
				Spike randomSpike = new Spike(oneASspikes.getSpikeAtTime(time)
						.copyPrefixSet());

				// add it to map with all random spikes
				if (randomSpikes.addSpike(time, randomSpike, as)) {
					selected++;
				}
			}
		}

		return randomSpikes;
	}