dev #24

Merged
altavir merged 14 commits from dev into master 2018-12-11 17:42:42 +03:00
2 changed files with 7 additions and 6 deletions
Showing only changes of commit 20a7c6c4f1 - Show all commits

View File

@ -17,7 +17,7 @@ class MultivariateBin(override val center: RealVector, val sizes: RealVector, va
return vector.asSequence().mapIndexed { i, value -> value in (center[i] - sizes[i] / 2)..(center[i] + sizes[i] / 2) }.all { it }
}
override val value: Number get() = counter.sum()
override val value get() = counter.sum()
internal operator fun inc() = this.also { counter.increment() }
override val dimension: Int get() = center.size
@ -51,8 +51,8 @@ class FastHistogram(
val center = indexArray.mapIndexed { axis, index ->
when (index) {
0 -> Double.NEGATIVE_INFINITY
actualSizes[axis] -> Double.POSITIVE_INFINITY
else -> lower[axis] + (index - 1) * binSize[axis]
actualSizes[axis] - 1 -> Double.POSITIVE_INFINITY
else -> lower[axis] + (index.toDouble() - 0.5) * binSize[axis]
}
}.toVector()
MultivariateBin(center, binSize)

View File

@ -14,10 +14,11 @@ class MultivariateHistogramTest {
(-1.0..1.0),
(-1.0..1.0)
)
histogram.put(0.6, 0.6)
histogram.put(0.55, 0.55)
val bin = histogram.find { it.value.toInt() > 0 }!!
assertTrue { bin.contains(Vector.ofReal(0.6, 0.6)) }
assertFalse { bin.contains(Vector.ofReal(-0.6, 0.6)) }
assertTrue { bin.contains(Vector.ofReal(0.55, 0.55)) }
assertTrue { bin.contains(Vector.ofReal(0.6, 0.5)) }
assertFalse { bin.contains(Vector.ofReal(-0.55, 0.55)) }
}
@Test