dev #24
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user