Skip to content

Instantly share code, notes, and snippets.

@jw3126 jw3126/so3.jl
Created Oct 5, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.