protected void calculatePrecisionRecallCurve(int index) {
		
		if( this.dataset == null)
			throw new RuntimeException("Error: impossible calculate precision-recall curves after the final calculation call");
		
		// Sort the dataset
		final String state = this.indexToValue.get(index);
		Collections.sort( this.dataset, new Comparator<IClassificationResult<TimeType>>() {
												public int compare(IClassificationResult<TimeType> trj1, IClassificationResult<TimeType> trj2) {
													Double p1 = trj1.getProbability(state);
													Double p2 = trj2.getProbability(state);
													if( Double.isNaN(p1))
														throw new IllegalArgumentException("Error: NaN probability value in trajectory " + trj1.getName());
													if( Double.isNaN(p2))
														throw new IllegalArgumentException("Error: NaN probability value in trajectory " + trj2.getName());
													
													return (int)Math.signum(p2 - p1);
												}
											});
		
		
		// Initialization
		double P = this.classPositiveNumber[index];
		
		// Calculate Precision-recall curve and AUC
		double p1, p2 = -1;
		double FP = 0.0, TP = 0.0;
		double prec = 1.0, precPrev = 1.0;
		double rec = 0.0, recPrev = 0.0;
		this.AUCPrecRec[index] = 0.0;
		List<double[]> pRCurve = new LinkedList<double[]>();
		IClassificationResult<TimeType> trj1 = null, trj2 = null;
		
		// Initialization
		double[] data = new double[2];
		data[0] = rec;	data[1] = prec;
		pRCurve.add(data);
		trj1 = this.dataset.get(0);
		for( int i = 1; i <= this.datasetDimension(); ++i) {
			
			p1 = trj1.getProbability(state);
			// Get trajectory
			if( i < this.datasetDimension()) {
				trj2 = this.dataset.get(i);
				p2 = trj2.getProbability(state);
			} else
				trj2 = null;
			
			// Update counts
			if( trj1.getNodeValue(0, trj1.getNodeIndexing().getClassIndex()).equals(state))
				++TP;
			else
				++FP;
			if( TP+FP == 0)				// precision
				prec = 1.0;
			else
				prec = TP/(TP+FP);
			rec = TP/P;					// recall
			
			if(  trj2 == null || p1 != p2) {
				data = new double[2];
				data[0] = rec;	data[1] = prec;
				pRCurve.add(data);
				this.AUCPrecRec[index] += trapezoidArea(rec,recPrev,prec,precPrev);
				precPrev = prec;
				recPrev = rec;
			}
			trj1 = trj2;
		}
		this.precRec.set(index, pRCurve);
	}