Struct CoinFlipSequence

Source
pub struct CoinFlipSequence<R> { /* private fields */ }
Expand description

§A sequence of Coin flips. Contains random Number generator

Implementations§

Source§

impl<R> CoinFlipSequence<R>
where R: Rng,

Source

pub fn new(n: usize, rng: R) -> Self

Create new coin flip sequence

  • length n
  • use rng as random number generator
Source§

impl<R> CoinFlipSequence<R>

Source

pub fn head_count(&self) -> usize

Count how often Head occurs in the Coin flip sequence

Source

pub fn update_head_count(&self, step: &CoinFlipMove, head_count: &mut usize)

  • Calculate the head count, if a previous head count of the ensemble and the markov steps leading to the current state are known
  • head_count is updated
  • might panic if step was not the markov step leading from the ensemble with head_count to the current ensemble - if it does not panic, the result will be wrong
Source

pub fn max_heads_in_a_row(&self) -> usize

Count many times Head occurred in a row

  • uses maximum value, i.e., for the sequence HHTHHHT it will return 3

Trait Implementations§

Source§

impl<R: Clone> Clone for CoinFlipSequence<R>

Source§

fn clone(&self) -> CoinFlipSequence<R>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<R: Debug> Debug for CoinFlipSequence<R>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de, R> Deserialize<'de> for CoinFlipSequence<R>
where R: Deserialize<'de>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<R> HasRng<R> for CoinFlipSequence<R>
where R: Rng,

Source§

fn rng(&mut self) -> &mut R

Access RNG Read more
Source§

fn swap_rng(&mut self, rng: &mut R)

If you need to exchange the internal rng Read more
Source§

impl<R> MarkovChain<CoinFlipMove, ()> for CoinFlipSequence<R>
where R: Rng,

Source§

fn m_step(&mut self) -> CoinFlipMove

Perform a markov step

Source§

fn m_steps(&mut self, count: usize, steps: &mut Vec<CoinFlipMove>)

§Only implemented for testcases

Default implementation would suffice

Source§

fn m_steps_acc<Acc, AccFn>( &mut self, count: usize, steps: &mut Vec<CoinFlipMove>, acc: &mut Acc, acc_fn: AccFn, )
where AccFn: FnMut(&Self, &CoinFlipMove, &mut Acc),

§Only implemented for testcases

Default implementation would suffice

Source§

fn undo_steps(&mut self, steps: &[CoinFlipMove], res: &mut Vec<()>)

§Only implemented for testcases

Default implementation would suffice

Source§

fn undo_steps_quiet(&mut self, steps: &[CoinFlipMove])

§Only implemented for testcases

Default implementation would suffice

Source§

fn steps_accepted(&mut self, _steps: &[CoinFlipMove])

§Only implemented for testcases

Default implementation would suffice

Source§

fn steps_rejected(&mut self, _steps: &[CoinFlipMove])

§Only implemented for testcases

Default implementation would suffice

Source§

fn undo_step(&mut self, step: &CoinFlipMove)

undo a markov step, return result-stateif you want to undo more than one step see undo_steps Read more
Source§

fn undo_step_quiet(&mut self, step: &CoinFlipMove)

undo a markov, panic on invalid result statefor undoing multiple steps see undo_steps_quiet Read more
Source§

fn m_steps_quiet(&mut self, count: usize)

Markov steps without return Read more
Source§

fn m_step_acc<Acc, AccFn>(&mut self, acc: &mut Acc, acc_fn: AccFn) -> S
where AccFn: FnMut(&Self, &S, &mut Acc),

Accumulating markov step Read more
Source§

fn m_steps_acc_quiet<Acc, AccFn>( &mut self, count: usize, acc: &mut Acc, acc_fn: AccFn, )
where AccFn: FnMut(&Self, &S, &mut Acc),

Accumulating markov steps Read more
Source§

impl<R> Serialize for CoinFlipSequence<R>
where R: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<R> Freeze for CoinFlipSequence<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for CoinFlipSequence<R>
where R: RefUnwindSafe,

§

impl<R> Send for CoinFlipSequence<R>
where R: Send,

§

impl<R> Sync for CoinFlipSequence<R>
where R: Sync,

§

impl<R> Unpin for CoinFlipSequence<R>
where R: Unpin,

§

impl<R> UnwindSafe for CoinFlipSequence<R>
where R: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,