mirror of
https://github.com/corda/corda.git
synced 2024-12-22 06:17:55 +00:00
client: Add varargs convenience sampleBernoulli
This commit is contained in:
parent
6f8d92d368
commit
69fecf94d1
@ -153,6 +153,8 @@ fun <A> Generator.Companion.replicatePoisson(meanSize: Double, generator: Genera
|
|||||||
|
|
||||||
fun <A> Generator.Companion.pickOne(list: List<A>) = Generator.intRange(0, list.size - 1).map { list[it] }
|
fun <A> Generator.Companion.pickOne(list: List<A>) = Generator.intRange(0, list.size - 1).map { list[it] }
|
||||||
|
|
||||||
|
fun <A> Generator.Companion.sampleBernoulli(maxRatio: Double = 1.0, vararg collection: A) =
|
||||||
|
sampleBernoulli(listOf(collection), maxRatio)
|
||||||
fun <A> Generator.Companion.sampleBernoulli(collection: Collection<A>, maxRatio: Double = 1.0): Generator<List<A>> =
|
fun <A> Generator.Companion.sampleBernoulli(collection: Collection<A>, maxRatio: Double = 1.0): Generator<List<A>> =
|
||||||
intRange(0, (maxRatio * collection.size).toInt()).bind { howMany ->
|
intRange(0, (maxRatio * collection.size).toInt()).bind { howMany ->
|
||||||
replicate(collection.size, Generator.doubleRange(0.0, 1.0)).map { chances ->
|
replicate(collection.size, Generator.doubleRange(0.0, 1.0)).map { chances ->
|
||||||
|
Loading…
Reference in New Issue
Block a user