A robot data check can reject every ordinary value outside a numeric interval yet still accept a NaN. The issue is the exact Boolean expression: an unordered floating-point value does not behave like a real number that must lie either below, inside, or above the interval.

NaN means not a number in the floating-point representation. A system may use it for an unavailable or invalid sample, but the bit pattern alone does not identify the reason. Its comparison behavior must be considered before treating a Boolean result as measurement validity.

The following scalar examples use the documented behavior of ordinary Python floating-point comparisons. They are logical and arithmetic constructions, not executed robot data processing or hardware tests.

Compare two interval expressions

Invent an acceptable numerical interval from zero through ten, including both endpoints. For an ordinary finite real value x, two familiar expressions describe the same interval:

inside = (x >= 0) AND (x <= 10).

not_outside = NOT[(x < 0) OR (x > 10)].

For x = 4, both expressions are true. For x = −2, both are false. For x = 12, both are false. Under those inputs, the alternative forms appear interchangeable.

Now let x be an ordinary floating-point NaN. Python's comparison reference states that ordered comparisons with NaN are false. Thus x >= 0 and x <= 10 are both false, so inside is false.

The comparisons x < 0 and x > 10 are also false. Their OR is false, so negating it makes not_outside true. The expression has accepted the NaN without establishing that it represents a number between the bounds.

The two formulations disagree because the real-number ordering assumption used to transform them is unavailable for this input. A familiar Boolean rewrite can therefore change the behavior at invalid numerical values.

Equality and inequality need separate statements

For a scalar NaN n under these ordinary floating-point comparisons, n == n is false, while n != n is true. It would be incorrect to summarize the behavior by saying every comparison involving NaN is false.

Neither result means that a physical sensor changed between two reads. The expression compares a special numerical value according to its representation rules.

A comparison against a separately constructed NaN is also not a normal equality test for identifying missing data. A named numerical predicate makes the intended classification clearer than treating a NaN as an ordinary sentinel that should equal itself.

These statements concern scalar value comparisons. Container equality, object identity, and specialized numerical types can have additional behavior and are outside this example.

Finiteness is a declared preliminary condition

NumPy's official isfinite reference defines a predicate that excludes both NaN and positive or negative infinity. For an interpretation requiring a bounded finite reading, that numerical classification can be kept separate from the interval comparison.

Consider the values NaN, positive infinity, −2, 4, and 12. Only −2, 4, and 12 are finite. Applying the invented inclusive interval criterion to those finite candidates retains only four.

The finite negative value −2 fails because of the interval, while NaN fails because it is not finite. Those are different reasons that can be retained in a processing record rather than merged into one unexplained rejected count.

A finite value still need not be a valid physical measurement. Wrong units, a stale timestamp, an unsupported calibration, or an out-of-context channel can all produce finite numbers. Finiteness supplies a numerical condition, not a complete sensor-quality policy.

Keep missing-sample treatment visible in a statistic

Use an original four-position sample record [2, 4, NaN, 8]. Assume NaN marks one unavailable observation and the other three values are the retained finite readings.

If the intended statistic is the arithmetic mean of retained readings, their sum is fourteen and their count is three. The result is 14/3, approximately 4.666667.

If the unavailable position is instead replaced with zero and all four positions are averaged, the result is 14/4 = 3.5. The denominator and the implied data have changed.

The zero-filled result would be correct for a genuinely observed record [2, 4, 0, 8]. It is not justified merely by the absence of the third reading. The unavailable value could have been zero, another finite value, or something outside the stated measurement model.

The retained-reading mean also needs its coverage: three used positions out of four. Reporting only 4.666667 would conceal that the statistic omitted one position and represents the available subset rather than a fully observed four-sample record.

An explicit ignore-NaN reduction has a contract

NumPy's nanmean documentation describes averaging non-NaN elements using their non-NaN count. That matches the denominator choice of three for the invented record, assuming the three remaining values are those intended for the statistic.

Ignoring NaNs is not the same predicate as retaining only finite values. An infinity is not a NaN, so a policy that requires finiteness should make that criterion explicit rather than infer it from a function name containing nan.

For an all-NaN slice, the documented nanmean result is NaN with a RuntimeWarning. There is no retained-value mean to compute from an empty usable set. Replacing that absence with a numeric zero would again introduce an application assumption.

The choice to drop a sample also does not establish that missingness was random. If unavailable samples cluster during particular events, an average of the remaining record may describe a systematically different subset. The four invented positions cannot determine that missing-data mechanism.

Preserve the reason alongside the value

A useful robot sample record retains the raw numerical classification, physical-validity status where known, and the selection rule used by later statistics. Counted, omitted, and substituted observations should remain distinguishable.

The range-check example makes the boundary concrete: not being proven below zero or above ten does not prove a NaN is an in-range reading. Naming numerical validity before interpreting the Boolean result prevents that missing ordering information from silently becoming acceptance.

Sources checked October 23, 2026

Python 3.14 Language Reference, Expressions, Value Comparisons:

https://docs.python.org/3.14/reference/expressions.html

NumPy 2.3, numpy.isfinite:

https://numpy.org/doc/2.3/reference/generated/numpy.isfinite.html

NumPy 2.3, numpy.nanmean:

https://numpy.org/doc/2.3/reference/generated/numpy.nanmean.html

All sample values, intervals, and calculations are original hypothetical examples. No sensor pipeline or numerical reduction library was executed.

Illustration note: The site-library robot beside a laptop is a concept illustration. It does not show invalid sensor data, a measured missing-sample rate, or a verified validation system.