Histogram with non-equal bin widths

19 views
Skip to first unread message

blaz...@gmail.com

unread,
Jan 9, 2025, 9:06:13 AMJan 9
to ArrayFire Users
Hi all,

I want to compute a histogram of a large unsorted array (>1e8 elements) with non-equal bin widths (order of 1e6 widths, sorted array). 
Is there a way to do this with existing ArrayFire functions?
The af::histogram() only supports equally sized bins in my understanding.

Simple example:

Source array:
20, 4, 150, 22, 400, 333, 222, 410, 490....

Bin position values array:
0, 10, 14, 18, 50, 100, 110, 250, 350, 500
(Bin widths as an alternative definition:
10, 4, 4, 32, 50, 10, 140, 100, 150)

Resulting histogram array:

1, 0, 0, 2, 0, 0, 2, 1, 3

I am thinking of a lookup or some arithmetic way of doing this but I imagine it will be extremely inefficient. If my bin widths are a multiplication of a specific width I think this is easy, but in my application, it might not be guaranteed.

Thanks for any suggestions,

Matus
Reply all
Reply to author
Forward
0 new messages