Skip to main content
replaced http://math.stackexchange.com/ with https://math.stackexchange.com/
Source Link

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 1/x, 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).

distribution after 20000 iterations

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 1/x, see 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).

distribution after 20000 iterations

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 1/x, see 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).

distribution after 20000 iterations

added 1 character in body
Source Link
FlipTack
  • 14.7k
  • 3
  • 54
  • 101

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 yiedlsyields a uniformly distributed random number in the interval (0,1) but rand^2 isn't uniformy distributed anymore, the probability density function follows 1/x, see 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 strechstretch 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).

distribution after 20000 iterations

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 yiedls a uniformly distributed random number in the interval (0,1) but rand^2 isn't uniformy distributed anymore, the probability density function follows 1/x, see 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 strech 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).

distribution after 20000 iterations

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 1/x, see 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).

distribution after 20000 iterations

added 24 characters in body
Source Link

Matlab, 24 17 bytes

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 yiedls a uniformly distributed random number in the interval (0,1) but rand^2 isn't uniformy distributed anymore, the probability density function follows 1/x, see 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 strech 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).

distribution after 20000 iterations

Matlab, 24 17 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 yiedls a uniformly distributed random number in the interval (0,1) but rand^2 isn't uniformy distributed anymore, the probability density function follows 1/x, see 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 strech 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).

distribution after 20000 iterations

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 yiedls a uniformly distributed random number in the interval (0,1) but rand^2 isn't uniformy distributed anymore, the probability density function follows 1/x, see 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 strech 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).

distribution after 20000 iterations

golfed out floor(x)
Source Link
Loading
added 298 characters in body
Source Link
Loading
Source Link
Loading