1
$\begingroup$

This question already has an answer here:

I need a uniform distribution on the unit circle

(x; y) : x^2 + y^2 <= 1 

with the density

f(x) = (2/Pi) Sqrt[1-x^2]

as a marginal distribution of pairs considered in point e.

I have no idea how to implement this and would appreciate any help.

$\endgroup$

marked as duplicate by J. M. is away Nov 1 '17 at 11:05

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 3
    $\begingroup$ Please try to get a basic knowledge of the Mathematica syntax before asking $\endgroup$ – Dr. belisarius Oct 22 '14 at 12:16
6
$\begingroup$

For a uniform distribution on the unit circle you want the angle to be uniform on {0, 2Pi}

thetaDist = UniformDistribution[{0, 2 Pi}];

xDist = TransformedDistribution[
   Cos[theta], theta \[Distributed] thetaDist];

Assuming[-1 < x < 1, PDF[xDist, x] // Simplify]

1/(Pi*Sqrt[1 - x^2])

Verifying that this is properly scaled

Integrate[PDF[xDist, x], {x, -1, 1}]

1

ListPlot[{Cos[#], Sin[#]} & /@
  RandomVariate[thetaDist, 200],
 AspectRatio -> Automatic]

enter image description here

Alternatively,

ListPlot[
 Flatten[
  {{#, Sqrt[1 - #^2]}, {#, -Sqrt[1 - #^2]}} & /@
   RandomVariate[xDist, 200],
  1],
 AspectRatio -> Automatic]

enter image description here

$\endgroup$
  • $\begingroup$ @wolfies - the points on (as opposed to within) the unit circle are the points {Cos[theta], Sin[theta]} with theta uniformly distributed on {0, 2Pi}. The distribution of x is TransformedDistribution[ Cos[theta], theta \[Distributed] thetaDist] For a given x, the corresponding ys on the unit circle are just Sqrt[1-x^2] and -Sqrt[1-x^2]. Hence the mapping of {{#, Sqrt[1 - #^2]}, {#, -Sqrt[1 - #^2]}} onto the list of random x values. $\endgroup$ – Bob Hanlon Jun 29 '17 at 18:34
3
$\begingroup$

Since V10.2, there is RandomPoint:

pts = RandomPoint[Disk[], 2000];
Graphics[{
  Circle[],
  Red, Point@pts}]

Mathematica graphics

(If the unit circle was desired, use Circle[] in place of Disk[].)

$\endgroup$
0
$\begingroup$

Just to provide other insights. RandomPoint as per MichaelE2 versus user defined probability distribution and confirmation desired marginal distribution:

pd = ProbabilityDistribution[
  Piecewise[{{1/Pi, 0 < x^2 + y^2 <= 1}}], {x, -1, 1}, {y, -1, 1}]
md = MarginalDistribution[pd, 1]
PDF[md, x]
Show[Histogram3D[pts = RandomPoint[Disk[], 100000], Automatic, "PDF"],
  Plot3D[PDF[pd, {x, y}], {x, -1, 1}, {y, -1, 1}, 
  PlotStyle -> {Blue, Opacity[0.5]}, Mesh -> None]]
Show[Histogram[pts[[All, 1]], Automatic, "PDF"], 
 Plot[PDF[md, x], {x, -1, 1}]]

enter image description here

$\endgroup$
  • $\begingroup$ BTW, WignerSemicircleDistribution[] is built-in. $\endgroup$ – J. M. is away Dec 19 '16 at 7:45
  • $\begingroup$ @J.M. yes thank you. I just wanted to illustrate MarginalDistribution for user-defined probability distribution. Your comment is instructive (as usual). :) Best wishes for the festive season. $\endgroup$ – ubpdqn Dec 19 '16 at 8:09

Not the answer you're looking for? Browse other questions tagged or ask your own question.