public int sampleState() throws RuntimeException {
		
		if( !this.validatedCIMs())
			throw new IllegalStateException("Error: CIMs are not validated");
		
		if( this.isStaticNode())						// if the node is static
			return DiscreteModel.sample(this.getCIM(this.getCurrentParentsEntry())[0]);
		else if( !this.isInstanced())					// if the node is continuous but not instanced
			throw new IllegalStateException("Error: the next state can be calculated only for instanced continuous nodes");
		
		// If the node is continuous and it is instanced
		int stateIndex = this.getCurrentStateIndex();
		double[] pDistr = (this.getCIM(this.getCurrentParentsEntry())[stateIndex]).clone();
		if( pDistr.length < 2)
			throw new IllegalStateException("Error: in continuous node to jump to the next state you need at least 2 states");
		if( pDistr[stateIndex] == 0)
			throw new IllegalStateException("Error: the node it is in an absorbing state. New states can not be sampled");
		
		for(int i = 0; i < pDistr.length; ++i) 			// generate the probability distribution
			if( i != stateIndex)
				pDistr[i] /= -pDistr[stateIndex];		
		pDistr[stateIndex] = 0.0;

		return DiscreteModel.sample(pDistr);
	}