This demo graphs a density function ρ(x) for some interval and then finds the center of mass of that interval.

Changing "rhoMin" (estimated minimum value of ρ(x) and "rhoMax" estimated maximum value of ρ(x)) is optional. Doing so will improve the coloring of the graph (cyan at "rhoMin", red at "rhoMax").