0
$\begingroup$

Suppose you have values and classify them in a histogram. In pseudo code this may look like this:

foreach value
  foreach bucket
    if(value > bucket.lowerBound && value <= bucket.upperBound)
      bucket.count = bucket.count + 1

Is there a mathematical notation for this selection task?

Suppose $i$ is an index denoting the bucket and $j$ an index of the values. Does a nice compact notation exist for writing the count $c_i$ in bucket $i$ as a function of the lower $l_i$ and upper $u_i$ bounds of bucket $i$, akin to

$ c_i = ... someNotation (v_j, l_i, u_i)$

Or maybe a matrix notation could better fit? With $C$ the vector of counts, $V$ the vector of values and $U$,$L$ the vectors of bounds.

$C = ...$

$\endgroup$
1
$\begingroup$

The indicator function is defined as \begin{align} \mathbf{1}_A(x) :=\begin{cases} 1 &\text{if } x \in A, \\ 0 &\text{if } x \notin A. \end{cases} \end{align} So you could rewrite your expression as \begin{align} c_i = \sum_{j} {1}_{[l_i,r_i]}(x_j) \end{align} But I don't know, whether there is a matrix notation.

Edit: It might be a problem that you check for $\quad left < x \leq right$ and not $ left \leq x \leq right$

$\endgroup$
  • $\begingroup$ Thanks for that. About your edit, I need to avoid duplicate counting so need to have strict inequality on one side: left<x≤right $\endgroup$ – Philipp Mar 5 '13 at 13:59
  • $\begingroup$ Ah okay, you could write it as $1_{(l_i,r_i]}$ but this does not really change the fact that you have no matrix representation. $\endgroup$ – k1next Mar 5 '13 at 14:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.