Description
Approximate an observation mean using bin midpoints weighted by their supplied masses.
Histogram edges divide a numeric coordinate axis into ordered bins, while each bin mass represents a count or nonnegative weight. Probability mass is a fraction of the total; probability density additionally divides by bin width and therefore has inverse coordinate units. An edge plan alone contains no observations.
Approximate an observation mean using bin midpoints weighted by their supplied masses.
When to use this tool
Use midpoint weighting when only aggregated bin masses are available and an approximate mean is acceptable.
How to use the tool and how it works
- Enter edges, mass using the definitions below.
- Run the operation. Resolve input-format errors before interpreting an output.
- Read result.mean, result.total, using the stated boundary, ordering, sign and absence conventions.
Represent each bin by its midpoint, computed as leftEdge/2+rightEdge/2. Sum midpoint times mass and divide by total mass, or return mean null when total is zero.1
| Input field | Meaning and units | Accepted input |
|---|---|---|
| edges | At least two finite strictly increasing coordinate edges. Their units define interval lengths and density units. | Dense list of at most 128 finite numbers, under the stated integer/range rules. |
| mass | Nonnegative finite bin masses in bin order; paired edge lists require mass.length=edges.length-1. | Dense list of at most 128 finite numbers, under the stated integer/range rules. |
| Output field | Interpretation |
|---|---|
| result | Object containing the fields below. |
| result.mean | Bin-midpoint-weighted mean coordinate, or null when total mass is zero. |
| result.total | Sum of supplied nonnegative bin mass. |
{
"input": {
"edges": [
0,
2,
4
],
"mass": [
1,
3
]
},
"output": {
"result": {
"mean": 2.5,
"total": 4
}
}
} Limitations and assumptions
- The midpoint-weighted mean approximates the mean of underlying observations. It cannot recover within-bin locations from mass alone.
- Edge lists contain at least two finite strictly increasing numbers. A mass array paired with edges has exactly one nonnegative finite mass per interval. Other mass-only operations accept empty arrays. Floating-point calculations do not imply exact decimal arithmetic or recover observations inside a bin.
- Every declared outer field is required and unknown outer fields are rejected. Strings and JSON text have size limits, lists are bounded to 128 entries, and JSON nesting/node counts are bounded. Tighter operation-specific bounds stated above take precedence.
- Numeric outputs must remain finite and within safe-integer magnitude. Original record indexes and cell coordinates are zero-based; stated half-open ranges exclude their end.
Alternative or Complementary methods
Keep edge definitions with mass arrays. Use common-boundary coarsening and whole-bin merging for aligned comparisons; use observation-level data when a calculation requires locations within bins.
References
Similar or alternative tools
- Histogram Bin Weight Density Table
Normalize bin masses by total mass and bin width to calculate probability densities, returning nulls for zero total.
- Histogram Adjacent Bin Merge Plan
Merge adjacent whole histogram bins according to explicit retained boundary indexes.