Creating Random Numbers
How to create random number in Julia and R? The following table translates the most common Julia commands into R language.
Julia  R  

Create uniform random numbers 

A = rand(10) 
A = runif(10) 

Create normal random numbers  
A = randn(10) 
A = rnorm(10) 

Create normal random numbers (mean=1,std=2) 

using Distributions A = rand(Normal(1,2),10) 
A = rnorm(10,1,2) 

Create Gamma distributed random numbers (shape=1,scale=2) 

using Distributions A = rand(Gamma(1,2),10) 
A = rgamma(10, shape = 1, scale = 2) 

Create Beta distributed random numbers (alpha=1,beta=2) 

using Distributions A = rand(Beta(1,2),10) 
A = rbeta(10,1,2) 
Complete JuliaR Cheatsheet
1) Creating Vectors
2) Creating Matrices
3) Creating Random Numbers
4) Manipulating Vectors and Matrices
5) Accessing Vector/Matrix Elements
Advertisements
5 thoughts on “JuliaR Cheatsheet – Creating Random Numbers”