Created
September 2, 2016 03:48
-
-
Save chipkent/c8e3acc4f64bd78db4fe40f2c42072f2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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