Package space.kscience.kmath.chains

Types

BlockingIntChain
Link copied to clipboard
common
abstract class BlockingIntChain : Chain<Int>
Performance optimized chain for integer values
BlockingRealChain
Link copied to clipboard
common
abstract class BlockingRealChain : Chain<Double>
Performance optimized chain for real values
Chain
Link copied to clipboard
common
interface Chain<out R> : Flow<R>
A not-necessary-Markov chain of some type
ConstantChain
Link copied to clipboard
common
class ConstantChain<out T>(value: T) : Chain<T>
A chain that repeats the same value
MarkovChain
Link copied to clipboard
common
class MarkovChain<out R : Any>(seed: suspend () -> R, gen: suspend (R) -> R) : Chain<R>
A stateless Markov chain
SimpleChain
Link copied to clipboard
common
class SimpleChain<out R>(gen: suspend () -> R) : Chain<R>
A simple chain of independent tokens.
StatefulChain
Link copied to clipboard
common
class StatefulChain<S, out R>(state: S, seed: S.() -> R, forkState: (S) -> S, gen: suspend S.(R) -> R) : Chain<R>
A chain with possibly mutable state.

Functions

asChain
Link copied to clipboard
common
fun <T> Iterator<T>.asChain(): Chain<T>
fun <T> Sequence<T>.asChain(): Chain<T>
asSequence
Link copied to clipboard
fun <R> Chain<R>.asSequence(): Sequence<R>
Represent a chain as a sequence
collect
Link copied to clipboard
common
fun <T, R> Chain<T>.collect(mapper: suspend (Chain<T>) -> R): Chain<R>
Map the whole chain
collectWithState
Link copied to clipboard
common
fun <T, S, R> Chain<T>.collectWithState(state: S, stateFork: (S) -> S, mapper: suspend S.(Chain<T>) -> R): Chain<R>
cumulativeSum
Link copied to clipboard
common
@ExperimentalCoroutinesApi()
fun <T> Flow<T>.cumulativeSum(space: SpaceOperations<T>): Flow<T>
filter
Link copied to clipboard
common
fun <T> Chain<T>.filter(block: (T) -> Boolean): Chain<T>
block must be a pure function or at least not use external random variables, otherwise fork could be broken
iterator
Link copied to clipboard
operator fun <R> Chain<R>.iterator(): Iterator<R>
Represent a chain as regular iterator (uses blocking calls)
map
Link copied to clipboard
common
fun <T, R> Chain<T>.map(func: suspend (T) -> R): Chain<R>
Map the chain result using suspended transformation.
mean
Link copied to clipboard
common
@ExperimentalCoroutinesApi()
fun <T> Flow<T>.mean(space: Space<T>): Flow<T>
zip
Link copied to clipboard
common
fun <T, U, R> Chain<T>.zip(other: Chain<U>, block: suspend (T, U) -> R): Chain<R>
Zip two chains together using given transformation