What does the histogram of values of a function on the y axis converge to? I have implemented the following algorithm:
. Let f be a real-valued function defined on [0,1], with values in [0,1]
. Prepare a histogram array with P bins, initialize all bins to zero.
. Divide the [0,1] segment on the Y axis into P segments of equal length.
. Let each bin of the histogram array Bi correspond to the segment Si
. Repeat N times:
    . Draw a random number x in [0,1] from a uniform distribution
    . Compute y = f(x)
    . Find which segment on the Y axis the value y "falls" in
    . Increment the corresponding bin in the histogram by 1
. End Repeat
. Plot resulting histogram

When run, this produces a histogram that approximates some sort of
distribution, and the histogram probably converges to said distribution
when both P and N tend to infinity.
What I have a hard time figuring out is what this distribution is,
or to put it slightly better, how it relates to the function f.
Help very much appreciated.
 A: This histogram will approximate distribution of $f(X)$ where $X\sim U(0,1)$ and $f(x)$ is bounded to $[0,1]$. You are correct that in the limit of infinite samples and bins, the the approximation will be exact.
As for how it related to $f$, think of it this way.


*

*If $f(x)=c$ where $c$ is constant, then your histogram will just be a spike at $c$

*If $f(x)=cx$, then your histogram will simply re-produce a  uniform distribution over some bounded interval (based on the range of $f$).

*If $f(x)=x^p$, then the non-linearity will "concentrate" the values of the function around areas where the function is "flatter" and will diminish the histrogram values where the function is steep. The location of the "peak" of the historgram will depend on $p$, with $p<1$ shifting the peak to higher values and $p>1$ shifting it towards lower values.


Per OP Comments
To analytically calculate the density of $f(X)$, you need to first find the associated probability measure of $f$:
$\large P(f(X)\leq z)=m[x:f(x)\leq z]$ where $m[\cdot]$ is the $Lebesgue$ measure.
Now, to get the density, you need to differentiate the probability meaure wrt $z$:
$\large\frac{dP}{dz} = \frac{d(m[x:f(x)\leq z])}{dz}$ 
That's as far as you can go without knowing more about $f$
