Other databases have good functions for histogram... For example Hive offers histogram_numeric(numeric_column,b), where b is the "number non-uniformly spaced bins".
Is there a library for PostgreSQL that offers a similar function for numeric columns?
Important: this Wiki function is ugly, is not simple.