public static Vector getGradient(AController pacmanController, int numTrials) {
		Vector initialParameters = pacmanController.getPolicyParameters();
		double initialEvaluation = evalPolicy(pacmanController, numTrials);
		int dimension = initialParameters.getDimension();
		
		int runs = 2 * initialParameters.getDimension();
		double[][] parametersVariations = new double[runs][];
		double[][] parametersEvaluations = new double[runs][1];
		for (int i = 0; i < runs; i++) {
			Vector parametersVariation = Vector.getRandomVector(dimension, -15, 15);
			Vector newParameters = initialParameters.copy().add(parametersVariation);
			pacmanController.setPolicyParameters(newParameters);
			parametersVariations[i] = parametersVariation.getValues();
			parametersEvaluations[i][0] = evalPolicy(pacmanController, numTrials) - initialEvaluation;
		}
		
		pacmanController.setPolicyParameters(initialParameters);
		
		try {
			Matrix theta = new Matrix(parametersVariations);
			Matrix j = new Matrix(parametersEvaluations);
			Matrix g = (((((theta.transpose()).times(theta)).inverse()).times(theta.transpose())).times(j));
			return new Vector(g.getColumnPackedCopy());
		} catch (Exception e) {
			return new Vector(initialParameters.getDimension()); // 0 vector
		}
	}