Skip to content

Instantly share code, notes, and snippets.

@chipkent
Created September 2, 2016 03:48
Show Gist options
  • Save chipkent/c8e3acc4f64bd78db4fe40f2c42072f2 to your computer and use it in GitHub Desktop.
Save chipkent/c8e3acc4f64bd78db4fe40f2c42072f2 to your computer and use it in GitHub Desktop.
using Distributions
using BenchmarkTools
function lratio2{FT}(dd::Dict{FT,Tuple{Float64, ContinuousUnivariateDistribution}})
num::Float64 = 0.0
denom::Float64 = 0
for (k, v) in dd
pDiscrete = v[1]
pContinuousGivenDiscrete = 1.2
denom += pDiscrete * pContinuousGivenDiscrete
end
return num / denom
end
FT = Int
dd = Dict{FT,Tuple{Float64, ContinuousUnivariateDistribution}}()
# dd[1] = (0.1,TDist(0.1))
# dd[2] = (0.2,TDist(0.2))
dd[1] = (0.1,Normal(0.1))
dd[2] = (0.2,Normal(0.2))
for i in 1:10
dd[i] = (rand(1)[1],Normal(0.2))
end
lratio2(dd)
@benchmark lratio2(dd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment