Skip to content

Main content

Histogram Bin Weight Density Table

Explicit finite ordered histogram edges and nonnegative mass observations; normalize weights by total mass and bin width; zero-total observations have null densities, not zeros.

Loading tool…

Description

Normalize bin masses by total mass and bin width to calculate probability densities, returning nulls for zero total.

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.

Normalize bin masses by total mass and bin width to calculate probability densities, returning nulls for zero total.

When to use this tool

Use densities when comparing bins of different widths, keeping the coordinate units with the result.

How to use the tool and how it works

  1. Enter edges, mass using the definitions below.
  2. Run the operation. Resolve input-format errors before interpreting an output.
  3. Read result.total, result.densities, using the stated boundary, ordering, sign and absence conventions.

Sum all nonnegative bin masses. For positive total, divide each mass by the total and its corresponding edge width; for zero total return null for every density.1

Input fieldMeaning and unitsAccepted input
edgesAt 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.
massNonnegative 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 fieldInterpretation
resultObject containing the fields below.
result.totalSum of supplied nonnegative bin mass.
result.densitiesMass/(total×bin width) for each bin, or null in every position when total=0; units are inverse coordinate units.
json
{
  "input": {
    "edges": [
      0,
      1,
      3
    ],
    "mass": [
      2,
      2
    ]
  },
  "output": {
    "result": {
      "total": 4,
      "densities": [
        0.5,
        0.25
      ]
    }
  }
}

Limitations and assumptions

  • Density has inverse coordinate units. Its area over a bin equals that bin’s probability; the density values themselves need not sum to one or stay below one.
  • 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

  1. Tool behavior and example: Histogram Bin Weight Density Table — tool.io

Similar or alternative tools