orlox / SideKicks.jl

Statistical Inference to DEtermine KICKS on compact objects
GNU General Public License v3.0
2 stars 0 forks source link

Determine distributions of pre-explosion velocities #4

Open orlox opened 3 months ago

orlox commented 3 months ago

One critical thing that is missing is the capacity to determine the distribution of the components of the pre-explosion velocity. The idea here is to fit a distribution to an observed set of velocities, for instance, the radial velocity of the barycenter for a set of nearby binaries, which is accessible in the TMBM- and will be accesible in BLOeM.

Below is one example that samples a given normal and then does an MCMC on the sampled points to recover the parameters of the normal distribution

using Turing
using Distributions

# sample 1000 points from a normal distribution
d = Normal(85, 19)
vals = rand(d, 100)

# create an MCMC to infer sigma and mu from points
@model function infer_normal(vals)
    μ ~ Uniform(-1000.0,1000.0)
    σ ~ Uniform(0,1000.0)

    for i = 1:length(vals)
        vals[i] ~ Normal(μ,σ)
    end
end

model = infer_normal(vals)
iterations = 100_000
@time chain = sample(model, NUTS(10_000,0.8), iterations);

##
@show mean(chain[:μ]), std(chain[:μ]);
@show mean(chain[:σ]), std(chain[:σ]);

We should have a simple interface to do this from a list of velocities, and the outcome can then be fed to the the MCMC doing the kick inference. One important detail though is that this does not consider measurement errors, so that needs to be included.