Skip to content

Commit

Permalink
add bivariate tests
Browse files Browse the repository at this point in the history
  • Loading branch information
axsk committed May 18, 2017
1 parent 346874f commit 4a3680a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions test/bivariate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,11 @@ for X in ([0.0], [0.0,0.0], [0.0,0.5], [-0.5:0.1:0.5;])
@test all(k5.density .>= 0.0)
@test sum(k5.density)*step(k5.x)*step(k5.y) 1.0

k6 = kde([X X],(r,r);kernel=D, weights=ones(X)/length(X))
@test k4.density k6.density
end
end

k1 = kde([0.0 0.0; 1.0 1.0], (r,r), bandwidth=(1,1), weights=[0,1])
k2 = kde([1.0 1.0], (r,r), bandwidth=(1,1))
@test k1.density k2.density
6 changes: 3 additions & 3 deletions test/univariate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ using Base.Test
using Distributions
using KernelDensity

import KernelDensity: kernel_dist, default_bandwidth, kde_boundary, kde_range, tabulate, UniformWeights
import KernelDensity: kernel_dist, default_bandwidth, kde_boundary, kde_range, tabulate

for D in [Normal,Uniform,Logistic]
d = kernel_dist(D,0.5)
Expand Down Expand Up @@ -54,10 +54,10 @@ for X in ([0.0], [0.0,0.0], [0.0,0.5], [-0.5:0.1:0.5;])
@test sum(k5.density)*step(k5.x) 1.0

k6 = kde(X,r;kernel=D, weights=ones(X)/length(X))
@test_approx_eq k4.density k6.density
@test k4.density k6.density
end
end

k1 = kde([0.0, 1.], r, bandwidth=1, weights=[0,1])
k2 = kde([1.], r, bandwidth=1)
@test k1.density == k2.density
@test k1.density k2.density

0 comments on commit 4a3680a

Please sign in to comment.