Skip to content

Generate two random chords in the unit circle and simulate the probability they intersect each other using SAS.

Notifications You must be signed in to change notification settings

mariaob1201/simulation_probab_chords_intersection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Probability of Intersecting Chords

Problem Statement

Given a circle, two chords are drawn at random. The task is to find the probability that these chords will intersect.

Mathematical Formulation

Consider two chords represented as vectors p = (p1, p2) and q = (q1, q2) in the unit circle. The parametrization functions of the chords are denoted as lambda_p(s) = (1-s)p1 + sp2 and lambda_q(t). Chords intersect if there exist s0 and t0 such that lambda_p(s0) = lambda_q(t0). This is expressed as a matrix equation Ax = b, where x = (s, t) and A is formed by vectors (p1-p2) and (q1-q2).

Code Explanation

The provided code, written in SAS IML, simulates the probability of intersecting chords on the unit circle through random chord generation.

  1. IntersectSegsSimple Function: Finds the intersection between two 2D line segments. Assumes different slopes (nonsingular matrix).

  2. Simulation (Main Part): Generates random chords on the unit circle, simulates the probability of intersection, and prints the result.

Usage

  1. Ensure you have SAS IML installed.
  2. Run the code to simulate and estimate the probability.
  3. Modify the N variable to control the number of simulations.

Feel free to experiment with the code based on your requirements.

About

Generate two random chords in the unit circle and simulate the probability they intersect each other using SAS.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages