-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from itsdfish/auto-juliaformatter-pr
Automatic JuliaFormatter.jl run
- Loading branch information
Showing
31 changed files
with
625 additions
and
602 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,33 @@ | ||
# Note: poor performance | ||
|
||
|
||
|
||
# this may not be working properly | ||
|
||
|
||
cd(@__DIR__) | ||
using DifferentialEvolutionMCMC, Random, StatsBase, Distributions | ||
|
||
N = 30 | ||
# Parameters for each cluster, we assume that each cluster is Gaussian distributed in the example. | ||
μs = [-3.5, 0.0] | ||
# Construct the data points. | ||
data = mapreduce(c -> rand(MvNormal([μs[c], μs[c]], 1.), N), hcat, 1:2) | ||
data = mapreduce(c -> rand(MvNormal([μs[c], μs[c]], 1.0), N), hcat, 1:2) | ||
|
||
priors = ( | ||
idx = (Categorical([.5,.5]),N), | ||
μs = (Normal(0, 1),2), | ||
idx = (Categorical([0.5, 0.5]), N), | ||
μs = (Normal(0, 1), 2) | ||
) | ||
|
||
bounds = ((1,2),(0.0,Inf)) | ||
bounds = ((1, 2), (0.0, Inf)) | ||
|
||
function loglike(data, idx, μs) | ||
LL = 0.0 | ||
for (i,id) in enumerate(idx) | ||
LL += logpdf(MvNormal([μs[id], μs[id]], 1.0), data[:,i]) | ||
for (i, id) in enumerate(idx) | ||
LL += logpdf(MvNormal([μs[id], μs[id]], 1.0), data[:, i]) | ||
end | ||
return LL | ||
end | ||
|
||
model = DEModel(priors=priors, model=loglike, data=data) | ||
model = DEModel(priors = priors, model = loglike, data = data) | ||
|
||
de = DE(bounds=bounds, burnin=1000, priors=priors, Np=15) | ||
de = DE(bounds = bounds, burnin = 1000, priors = priors, Np = 15) | ||
n_iter = 2000 | ||
@elapsed chains = sample(model, de, n_iter, progress=true) | ||
@elapsed chains = sample(model, de, n_iter, progress = true) |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
using KernelDensity, Distributions, Interpolations | ||
import KernelDensity: kernel_dist | ||
kernel_dist(::Type{Epanechnikov}, w::Float64) = Epanechnikov(0.0, w) | ||
kernel(data) = kde(data; kernel=Epanechnikov) | ||
kernel(data) = kde(data; kernel = Epanechnikov) |
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
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
Oops, something went wrong.