Matlab, 24 18 bytes
char(floor(26*rand^2+65))
it looks like using floor(x)
isn't necessary as char
also takes non-integer inputs
char(25*rand^2+65)
not using ['' x]
instead of char(x)
so I won't get warning: implicit conversion from numeric to char for "purer" output.
rand
yields a uniformly distributed random number in the interval (0,1)
but rand^2
isn't uniformy distributed anymore, the probability density function follows , see heresee here.
with (b-a)*rand+a
one can shift the interval of the distribution from (0,1)
to (a,b)
, this also works with rand^2
.
because i use floor
i need to stretch the interval to (65,91)
so i don't lose "Z"
It might no be the shortest answer but i like the approach with using a uniform random distribution to get a non-uniform random distribution.
Below is the count for each generated numbers after 20000 iterations (using my first version of my answer).