Skip to content

Instantly share code, notes, and snippets.

View anazareth's full-sized avatar

Alex Nazareth anazareth

View GitHub Profile
@anazareth
anazareth / buffonneedle.m
Last active September 10, 2021 02:32
Monte Carlo simulation of Buffon's needle problem.
clc; clear
L = 1; % length of needle
num_needles = 1000; % number of needles to drop
a = 0; b = 10; % bounds (same for x and y) of 10 by 10 area
N = 10; % num points with which to plot lines
x = a:1:b; % x values for line plotting
y = repmat(a:1:b,length(x),1); % y values for line plotting
plot(x, y, 'b')