[英]How to generate points in R?
我尝试过这种方法,看看它,如果它有帮助。
# Creating 3 uniform data distributions
a = matrix(runif(100, 0, 5), ncol=2)
b = matrix(runif(100, 10, 15), ncol=2)
c = matrix(runif(100, 10, 15), ncol=2)
b[,1] = b[,1] - 10 # removing 10 units from x aixs
c[,2] = c[,2] - 10 # removing 10 units from y aixs
x <- rbind(a,b,c) # binding rowise
plot(x) # plot
# Creating 3 uniform data distributions
a = matrix(runif(100, 2, 4), ncol=2)
b = matrix(runif(100, 1, 5), ncol=2)
c = matrix(runif(100, 1, 5), ncol=2)
b[,1] = b[,1] /5 # scaling x axis by 5 units
c[,2] = c[,2] /5 # scaling y axis by 5 units
x <- rbind(a,b,c) # binding rowise
plot(x) # plot
另一种方法
# Creating normal distribution over X axis and uniform distribution over Y axis
a = cbind(rnorm(100, mean=3, sd=1),
runif(100, 0, 1))
# Creating uniform distribution over X axis and normal distribution over Y axis
b = cbind(runif(100, 0, 1),
rnorm(100, mean=3, sd=1))
# Creating normal distribution over both axis ranging from 2-4
c = matrix(runif(100, 2, 4), ncol=2)
# binding row wise 300 samples 100 from each cluster and plotting
plot(rbind(a, b, c))
希望能帮助到你!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.