Skip to content

Instantly share code, notes, and snippets.

@jw3126
Created October 5, 2018 12:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jw3126/541f53295809b5f473dc1bc558c7d768 to your computer and use it in GitHub Desktop.
Save jw3126/541f53295809b5f473dc1bc558c7d768 to your computer and use it in GitHub Desktop.
Haar Measure of distance Ball SO(3)
# https://math.stackexchange.com/questions/1049788/haar-measure-of-an-angle-distance-ball-in-so3
using StatsBase
using LinearAlgebra
using StatPlots
using Plots
using Rotations
function sample_angles(N)
map(1:N) do _
rot = rand(RotMatrix{3})
AngleAxis(rot).theta
end
end
N_bins = 100
N_samples = 10^5
wts = weights(fill(1.,N_samples))
edges = range(0,stop=pi,length=N_bins)
h = fit(Histogram, sample_angles(N_samples), wts, edges, closed=:left)
pdf(angle) = 1 - cos(angle)
plot(title="Pdf angle of rotation Haar Measure")
plot!(rad2deg.(edges)[2:end], N_bins*normalize!(h.weights,1), label="simulation")
plot!(rad2deg.(edges), pdf.(edges), label="pdf")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment