Suppose we have a continuous random variable $X$. We do not know its distribution function, but have $n$ i.i.d. samples.
I am looking for methods that quantize (discretize) $X$ into a categorical variable $\tilde{X}$ with $k$ level.
The most naive method is the uniform quantization, where each quantization bin has the same length. However, it seems more reasonable to set the length of bins according to empirical density of $X$, as shown in the below figure.
I think there must be some standard text that deals with my problem, but have not found one yet. I would be really grateful if you could point to an authoritative reference that covers this topic.
?hist
in R) $\endgroup$pandas.qcut
for implementation. $\endgroup$