protected double[] checkWeights(int length, double[] weights) {
		boolean damaged = false;
		// check for null
		if (weights == null) {
			damaged = true;
			weights = new double[length];
		}
		// check if all elements are zeros or if there are negative, NaN or Infinite elements
		else {
			boolean allZero = true;
			boolean illegalElement = false;
			for (int i = 0; i < weights.length && !illegalElement; i++) {
				if (weights[i] < 0 || Double.isNaN(weights[i]) || Double.isInfinite(weights[i])) illegalElement = true;
				allZero = (weights[i] == 0) && allZero;
			}
			damaged = allZero || illegalElement;
		}
		if (!damaged) return weights;
		System.out.println("WARNING: weights were not well defined. All elements set to 1.");
		Arrays.fill(weights, 1);
		return weights;
	}