Digitize Boundary Ownership determines which interval receives a value equal to a bin edge. NumPy digitize returns interval indices, so the meaning of an index depends on the edge order and the right parameter. The finite examples below use invented scalar values rather than sensor measurements or a fitted probability distribution.
Let the edge array be [2, 5, 9]. With right=False, an interior returned index i satisfies bins[i-1] less than or equal to x and x strictly less than bins[i]. Index 1 therefore represents the interval from 2 inclusive to 5 exclusive. Index 2 represents 5 inclusive to 9 exclusive.
Apply the function to the values [1, 2, 4, 5, 9, 10]. The returned indices are [0, 1, 1, 2, 3, 3]. The value 2 belongs to the interval beginning at 2, while 5 belongs to the next interval beginning at 5. The last edge 9 has no following bounded interval in this edge array.
These outputs are not the positions of matching values inside the input list. The two values 2 and 4 receive the same interval index even though they occupy different input positions. Likewise, the output is not an array of counts per interval; it contains one classification result for each supplied value.
![rightFalse[2,5),[5,9);rightTrue(2,5],(5,9].](https://rehash.oss-cn-shenzhen.aliyuncs.com/images/261123/6b039601a6865.png)
With right=True and the same increasing edges, the interior condition becomes bins[i-1] strictly less than x and x less than or equal to bins[i]. For the same six values, the indices become [0, 0, 1, 1, 2, 3]. The values equal to 2, 5 and 9 move to the side that includes the right edge.
The value 4 remains in interval 1 because it lies strictly between 2 and 5. This makes it a useful control value when reviewing the two modes. The change concerns equality at boundaries, rather than shifting every number or changing the edge locations.
The parameter name can be easy to misread. For increasing edges, right=True includes the right edge of each interior interval. It does not mean that every boundary value is moved toward a larger returned index. In this example the equal-edge indices become smaller when right changes from False to True.

Zero and len(bins) are valid classification outputs for values beyond the bounded interior intervals. Here len(bins) is 3. The caller must not blindly treat every returned index as a valid direct subscript into the three-element edge array, because index 3 lies beyond its final element.
Index 0 also needs semantic care. Reading bins[i-1] would become bins[-1] in Python, which retrieves the last edge rather than an imagined lower edge of the first outside region. A convenient indexing expression can therefore run without an exception while describing the wrong interval.
A clear report labels outside classifications separately before attempting to print bounded interval endpoints. The article does not invent extra edges at infinity or silently discard outside values. Such policies would belong to the consumer's application rather than the returned index alone.
The documented interface requires a one-dimensional monotonic edge array and also supports decreasing order with different inequalities. This article keeps the worked arithmetic increasing, so every displayed interval uses one consistent direction. A diagram for decreasing edges would need to restate its conditions rather than copy the increasing table unchanged.
The official implementation checks monotonicity and delegates the lookup to searchsorted with the appropriate side, reversing the edges and adjusting the result for decreasing order. The local test also confirms that a deliberately nonmonotonic edge array is rejected rather than sorted automatically.
For example, a report can mark index 1 as the first bounded interior interval only after stating the active equality rule. Under the default setting its endpoints are written [2,5), whereas under right=True they are written (2,5]. Those bracket choices carry information that the bare index 1 does not contain. Dropping the right setting from a saved result would therefore remove part of the classification definition.
Likewise, changing the edge array after classification would make old indices refer to different intervals. Preserve the original edge values with the output if the result needs later interpretation. This is a reproducibility requirement for the finite example, rather than a claim that digitize stores a copy of its configuration alongside every returned integer.
The useful comparison records each original value beside both returned indices, with the exact edge array and right setting in the caption. This lets a reader verify the three equal-edge cases while retaining interior and outside controls. The table is an original finite example, not a histogram estimated from real observations.
Related explanations appear in the array classification methods section and technical article archive. Primary references are the NumPy digitize documentation and NumPy official implementation.