Program for bivariate distribution for f(x, y) = 1/pi where x^2 + y^2 = 1

Reply
New Contributor
Posts: 2

Program for bivariate distribution for f(x, y) = 1/pi where x^2 + y^2 = 1

[ Edited ]

(a) [10] 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) [10] Draw the bivariate histogram for x and y. (c) [10] 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;

 

Super User
Posts: 19,033

Re: Program for bivariate distribution for f(x, y) = 1/pi where x^2 + y^2 = 1

[ Edited ]

This is invalid:

x^2

In SAS, the correct operator is **

 

x**2

http://support.sas.com/documentation/cdl/en/lrcon/69852/HTML/default/viewer.htm#p00iah2thp63bmn1lt20...

 

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.

New Contributor
Posts: 2

Re: Program for bivariate distribution for f(x, y) = 1/pi where x^2 + y^2 = 1

Thank you, I've gotten both x and y to vary between (-1,1), I'm still struggling to restrict it so that x^2 + y^2 <1 and output that data. Any suggestions or help would be appreciated!
Super User
Posts: 9,856

Re: Program for bivariate distribution for f(x, y) = 1/pi where x^2 + y^2 = 1

It is about data simulation, better post it at IML forum.

what doest f(x,y) looks like,what is its form ?

Super User
Posts: 9,856

Re: Program for bivariate distribution for f(x, y) = 1/pi where x^2 + y^2 = 1

SAS Super FREQ
Posts: 3,618

Re: Program for bivariate distribution for f(x, y) = 1/pi where x^2 + y^2 = 1

In addition to the excellent responses from @Reeza and @Ksharp, use PROC KDE to draw the bivariate histogram. The BIVAR statement and PLOTS=HISTOGRAM are what you want to use.

Ask a Question
Discussion stats
  • 5 replies
  • 119 views
  • 4 likes
  • 4 in conversation