Struct andys_morning_stroll::Expectation
source · pub struct Expectation<T: RandomWalk> {
pub freq_map: HashMap<u32, u32>,
pub cnt: u32,
/* private fields */
}Expand description
A struct to calculate the expected length of a random walk, for any type T: RandomWalk. We
will use this to calculate the expected values of walks on our Football and
KitchenFloor types.
Fields§
§freq_map: HashMap<u32, u32>A map from walk lengths to the frequency of occurences of walks of that length.
cnt: u32Count of the number of runs executed so far.
Implementations§
source§impl<T: RandomWalk> Expectation<T>
impl<T: RandomWalk> Expectation<T>
sourcepub fn calculate(&mut self, src: T::State, tgt: T::State, runs: u32) -> f32
pub fn calculate(&mut self, src: T::State, tgt: T::State, runs: u32) -> f32
Run the expectation computation. Internally, this calls walker.walk which does not take a
limit cut-off for walk lengths. Therefore, this function could take a long time if walks
can be extremely long or even diverege to infinity.
sourcepub fn calculate_with_limit(
&mut self,
src: T::State,
tgt: T::State,
runs: u32,
limit: u32
) -> f32
pub fn calculate_with_limit( &mut self, src: T::State, tgt: T::State, runs: u32, limit: u32 ) -> f32
Same as calculate but takes a limit argument which is passed to
RandomWalk::walk_until_limit in order to ensure the function
terminates, ideally in a reasonable time.