Hello! I have a question on uniform distribution. I want to plot n, say 20, points, uniformly distributed, in a circle, with radius=0.1 and center,say, (0.4, 0.8) I do not know how~ Thank you for your time. Yours Wolfgang Amadeus [[alternative HTML version deleted]]
ang<-runif(20,0,2*pi) x<-cos(ang) +0.4 y<-sin(ang) +0.8 plot(x,y,ylim=c(-3,3),xlim=c(-3,3)) -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Wolfgang?Amadeus Sent: Wednesday, January 20, 2010 5:26 AM To: r-help Subject: [R] question on runif Hello! I have a question on uniform distribution. I want to plot n, say 20, points, uniformly distributed, in a circle, with radius=0.1 and center,say, (0.4, 0.8) I do not know how~ Thank you for your time. Yours Wolfgang Amadeus [[alternative HTML version deleted]] ______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Oops forgot to include the radius ang<-runif(200,0,2*pi) x<-cos(ang)*.1 +0.4 y<-sin(ang)*.1 +0.8 plot(x,y) -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Wolfgang?Amadeus Sent: Wednesday, January 20, 2010 5:26 AM To: r-help Subject: [R] question on runif Hello! I have a question on uniform distribution. I want to plot n, say 20, points, uniformly distributed, in a circle, with radius=0.1 and center,say, (0.4, 0.8) I do not know how~ Thank you for your time. Yours Wolfgang Amadeus [[alternative HTML version deleted]] ______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
While I agree that this is someone's homework, it occur to me that we can mess him up a little more. He asked for 200 points *uniformly* distributed on (or in) a circle. Well, he did NOT say "uniform random distribution". So in fact the plot, "on" a circle would be theta <-seq(0,2*pi, by = pi/100 ) # plus or minus a couple radius<-1 plot({x,y converted from theta, radius}) I'm not quite sure how one generates 200 uniformly distributed points inside a circle,-- which btw means "on a disc" . Maybe simply requiring them to be arranged so that all nearest neighbor distances are the same :-) Carl