Esempio n. 1
0
void ttoggle_panel::set_value(const unsigned selected)
{
	if(selected == get_value()) {
		return;
	}
	state_num_ = selected % num_states();
	set_is_dirty(true);
}
Esempio n. 2
0
	void perturb_emissions( double amount=0.2 )
	{
		assert(amount <= 1.0); assert(amount >= 0.0);
		typedef typename Algo::probability_type P;
		typedef LogspaceDouble<P> logspace_t;

		const size_t N = num_states(*_model);
		const size_t S = num_symbols(*_model);

		for( size_t state=0; state < N; ++state)
		{
			if( _model->is_silent(state) ) continue;
			for( size_t symbol=0; symbol<S; ++symbol )
			{
				const P orig = logspace_t(_model->e(state, symbol), true);

				const P random = _random();

				const P perturbed =
					orig * (1-amount)
					+ random * amount;

				_model->SetEmissionProbability(state,
											   _model->get_symbol(symbol),
											   perturbed); // accepts probability in real space

			}
		}

		_model->normalize_emissions();
		
#ifndef NO_TESTS
		tests::test_emissions_valid_pdf<Algo>(*_model);
#endif //NO_TESTS	
		
	}
Esempio n. 3
0
// check_state_index checks that the specified index is within valid bounds. If
// it isn't, the member function throws a InvalidStateIndexError exception.
void TransitionFn::check_state_index(int index) const {
  if (index < 0 || index >= num_states())
    throw Util::InvalidStateIndexError(id_, index);
}
Esempio n. 4
0
	void set_value_bool(const bool value)
	{
		assert(num_states() == 2);
		return set_value(value);
	}
Esempio n. 5
0
	bool get_value_bool() const
	{
		assert(num_states() == 2);
		return get_value() != 0;
	}