How to transform data to uniform distribution (uniform percentiles)?
Hi: You can calculate the empirical cumulative distribution of the data. By this, I mean, given some observation in the sample, $x_i$, calculate $P(X &lt; x_{i})$ by calculating the proportion of observations that are  less than $x_{i}$ (i.e. the percentiles ). Then, do this for all the $x_{i}$ so that you have the cumulative distribution of the $x_{i}$.

Then, $P(X &lt; x)$ is uniform for a given value of $x$.

In fact, it seems like you already did this but the percentile values should be on the vertical axis and the values of the data should be on the x-axis.

Note that page 14 of this PDF explains the concept more clearly than I have.



Example Implementation

Below is a quick-and-dirty attempt to illustrate this answer.  The image below shows the original histogram of the Gaussian, the empirical cumulative distribution function of that data, and then the histogram of the converted data.



R Code Below

par(mfrow=c(3,1))
# First, generate some Gaussian numbers.
gaussian &lt;- rnorm(1000,0.0,0.05)
gh &lt;- hist(gaussian, breaks=1000)

empirical_cumulative_distribution &lt;- cumsum(gh$counts)/1000

plot(gh$mids, empirical_cumulative_distribution)


uniformize &lt;- function(x) {
  ans_x &lt;- x
  for (idx in seq(1,length(x))){
    max_idx &lt;- max(which(gh$mids &lt; x[idx]))
    ans_x[idx] &lt;- empirical_cumulative_distribution[max_idx]
  }
  return(ans_x)
}

uniform2 &lt;- uniformize(gaussian )
hist(uniform2, breaks=100)
par(mfrow=c(1,1))