Benchmarks
The benchmarks below were run on Julia version 1.11.5.
Default example
X = [40 30 20 10; 35 50 100 75; 30 80 70 120; 20 30 40 50]
u = [150, 300, 400, 150]
v = [200, 300, 400, 100]
@benchmark ipf(X, [u, v])
BenchmarkTools.Trial: 10000 samples with 1 evaluation per sample.
Range (min … max): 64.690 μs … 11.541 ms ┊ GC (min … max): 0.00% … 98.39%
Time (median): 69.510 μs ┊ GC (median): 0.00%
Time (mean ± σ): 74.515 μs ± 152.318 μs ┊ GC (mean ± σ): 3.37% ± 1.69%
▂▅▄▃▄▆███▇▆▅▄▃▃▃▂▂▁▁ ▁ ▁▁▁▁▂▂▁▁▁▁▂▁▁ ▂
██████████████████████████▇████████████████████▇▇▇▇▆▆▆▄▆▆▅▅▄ █
64.7 μs Histogram: log(frequency) by time 98.9 μs <
Memory estimate: 41.36 KiB, allocs estimate: 918.
Large contingency table
X = reshape(repeat(1:16, 625), 100, 100)
Y = reshape(repeat(1:5, 2000), 100, 100) + X
m = ArrayMargins(Y)
@benchmark ipf(X, m)
BenchmarkTools.Trial: 10000 samples with 1 evaluation per sample.
Range (min … max): 154.508 μs … 3.140 ms ┊ GC (min … max): 0.00% … 93.45%
Time (median): 165.382 μs ┊ GC (median): 0.00%
Time (mean ± σ): 181.752 μs ± 102.004 μs ┊ GC (mean ± σ): 5.34% ± 8.72%
█▇▆▄▃▁ ▃▂ ▂
██████▇███▇██▇▃▃▃▃▃▃▄▄▄▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▃▄▄▆▅▅▇ █
155 μs Histogram: log(frequency) by time 759 μs <
Memory estimate: 279.86 KiB, allocs estimate: 1011.
Six-dimensional contingency table
X = reshape(repeat(1:12, 100), 6, 4, 2, 5, 5)
Y = reshape(repeat(1:5, 240), 6, 4, 2, 5, 5) + X
m = ArrayMargins(Y)
@benchmark ipf(X, m)
BenchmarkTools.Trial: 9976 samples with 1 evaluation per sample.
Range (min … max): 468.241 μs … 10.663 ms ┊ GC (min … max): 0.00% … 94.31%
Time (median): 485.483 μs ┊ GC (median): 0.00%
Time (mean ± σ): 499.074 μs ± 223.238 μs ┊ GC (mean ± σ): 1.81% ± 3.90%
▂██▄ ▁▆▇▅▂
▂▄█████▇█████▇▅▄▄▃▄▄▄▄▃▃▃▃▃▃▂▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▃
468 μs Histogram: frequency by time 574 μs <
Memory estimate: 118.12 KiB, allocs estimate: 2035.