Ejemplo n.º 1
0
Vector Statistics::centeredRandomVariables(const Vector &X)
{
    Vector centeredVariables;
    qreal Mx = expectedValue(X);

    // центрирование
    for (Vector::ConstIterator it = X.constBegin(); it != X.constEnd(); ++it)
        centeredVariables << *it - Mx;

    return centeredVariables;
}
Ejemplo n.º 2
0
// Method that takes a state and gives an appropriate response
void MyAI::respondTo(const State state) const
{
	std::list<Choice> choice_list = allValidChoices(state);

	Choice max_choice = choice_list.front();

	for (std::list<Choice>::iterator itr = choice_list.begin(); itr != choice_list.end(); ++itr)
	{
		if (expectedValue(state,max_choice) < expectedValue(state,*itr)) max_choice = *itr;
		#ifdef _TEST_
			output << itr->to_s() << " with expected value: "  << expectedValue(state,*itr) << std::endl;
		#endif

	}

	#ifdef _TEST_
		output << "Best Choice was: " << max_choice.to_s() << " with expected value: " << expectedValue(state,max_choice) << std::endl;
	#else
		output << max_choice.toResponseValue() << std::endl;
	#endif
}
Ejemplo n.º 3
0
/**
 * FUNCTION NAME: Hi
 *
 * DESCRIPTION: This function is a helper function
 */
double FBF::Hi(int bloomFilterIndex) {
	trace.funcEntry("FBF::Hi");
	if ( -1 == bloomFilterIndex ) {
		trace.funcExit("FBF::Hi");
		return 0;
	}
	else {
		trace.funcExit("FBF::Hi");
		//return expectedValue(populateNi(bloomFilterIndex), fbf[present].getSaltSize() - Hi(bloomFilterIndex-1));
		// 12/02/14
		return expectedValue(populateNi(bloomFilterIndex), fbf[present].getSaltSize() - 1);
	}
}
Ejemplo n.º 4
0
void test_expression_evaluator() {
	GLECSVData reader;
	reader.setDelims(",");
	reader.read("unit-tests/expressions.txt");
	GLECSVError* error = reader.getError();
	unit_test(error->errorCode == GLECSVErrorNone);
	std::auto_ptr<GLEPolish> polish(new GLEPolish());
	polish->initTokenizer();
	for (unsigned int i = 0; i < reader.getNbLines(); i++) {
		unit_test(reader.getNbColumns(i) == 2);
		string expression(reader.getCellString(i, 0));
		string expectedValue(reader.getCellString(i, 1));
		str_remove_quote(expression);
		str_remove_quote(expectedValue);
		test_expression_evaluator_each(polish.get(), expression, expectedValue);
	}
}