02-28-2017 06:40 PM - edited 02-28-2017 06:41 PM
(a)  Write a program to draw 100,000 observations from the following bivariate distribution which is uniform over a unit circle. f(x, y) = 1/ℼ where x2 + y2 < 1
(b)  Draw the bivariate histogram for x and y. (c)  Draw the (marginal) histogram for x .
I've tried transforming x and y so that they vary between (-1,1) and then using the Do while loop so that x2 + y2< 1. Still new to SAS so any would be great.
This is my code so far:
data test; Do i=1 to 10000; Do While x^2 + b^2 <1; x=2*ranuni(111)-1; y=2*ranuni(111)-1; z= x^2 + b^2 <1; end; output; end; run; ods graphics on; proc bivariatete data=test; var x; var y; var z; histogram z; run; ods graphics off;
02-28-2017 06:45 PM - edited 02-28-2017 06:49 PM
This is invalid:
In SAS, the correct operator is **
For the histogram, use PROC UNIVARIATE or PROC SGPLOT.
PS. You have a lot of other errors in your code. I would suggest doing one step at a time, getting that working and then moving forward. Look at Rick Wicklin blog or book for informaiton on how to simulate data in SAS. If you're a student, since this is clearly homework, your university library may have a digital version available for you to peruse.
02-28-2017 08:37 PM
03-01-2017 09:58 AM