## Is your feature request related to a problem?

#4947 added a new query to the backend – time to convert. It works well, just one point is kind of rough: bin width and count.

## Describe the solution you'd like

Currently the number of bins is hardcoded. Ideally we should have two options:
- return a user-specified number of bins,
- otherwise infer a reasonable number of bins using some algorithm (auto option).

@alexkim205 [suggested](https://github.com/PostHog/posthog/issues/4855#issuecomment-872423877) the [Freedman-Diaconis rule](https://en.wikipedia.org/wiki/Freedman%E2%80%93Diaconis_rule) for determining bin width (and interval based on that), but unfortunately from my testing its formula would not be the most practical – it's great for keeping a pretty constant "smoothness" of the histogram esp. with normal distribution, but we face some additional constraints that make it less than ideal:
- we can't have histograms too dense visually in the UI, from my testing a practical limit is 60 bins (above that it gets too dense),
- our data generally doesn't follow much of a normal distribution.

Clamping may help though, or maybe a different formula may work better outright – I'll be testing this.

## Additional context

Issue pertaining to the experience of time to convert: #4855

#### *Thank you* for your feature request – we love each and every one!

ee/clickhouse/queries/funnels/funnel_time_to_convert.py
query = f"""
            WITH step_runs AS (
                {steps_per_person_query}
            ), (
                -- Automatic bin interval which makes sure that there's always number_of_bins bins
                -- and that each step run will belong to one bin in results
                SELECT ceil(max(step_{to_step}_average_conversion_time) / {number_of_bins}) AS bin_base_seconds FROM step_runs
            ) AS bin_base_seconds
            SELECT
                bin_to_seconds,
                person_count
            FROM (
                -- Calculating bins from step runs
                SELECT
                    floor(step_{to_step}_average_conversion_time / bin_base_seconds + 1) * bin_base_seconds AS bin_to_seconds,
                    count() AS person_count
                FROM step_runs
                WHERE step_{to_step}_average_conversion_time IS NOT NULL
                GROUP BY bin_to_seconds
            ) results
            FULL OUTER JOIN (
                -- Making sure number_of_bins bins are returned
                -- Those not present in the results query due to lack of data simply get person_count 0
                SELECT (number + 1) * bin_base_seconds AS bin_to_seconds FROM numbers({number_of_bins})
            ) fill
            USING (bin_to_seconds)
            ORDER BY bin_to_seconds
            SETTINGS allow_experimental_window_functions = 1"""
        return query