Skip to content

Commit

Permalink
updating code to current personal preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
joshday committed Jun 25, 2023
1 parent d5c5ba9 commit bece9cb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 21 deletions.
14 changes: 6 additions & 8 deletions src/bivariate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,13 @@ end
function Base.show(io::IO, o::Ash2)
println(io, "Ash2")
f, l, s = round.((first(o.rngx), last(o.rngx), step(o.rngx)), digits=4)
print(io, "X:")
println(io, " > edges | $f : $s : $l")
println(io, " > kernel | $(o.kernelx)")
println(io, " > m | $(o.mx)")
println(io, "X: • edges | $f : $s : $l")
println(io, " • kernel | $(o.kernelx)")
println(io, " • m | $(o.mx)")
f, l, s = round.((first(o.rngy), last(o.rngy), step(o.rngy)), digits=4)
print(io, "Y:")
println(io, " > edges | $f : $s : $l")
println(io, " > kernel | $(o.kernely)")
println(io, " > m | $(o.my)")
println(io, "Y: • edges | $f : $s : $l")
println(io, " • kernel | $(o.kernely)")
println(io, " • m | $(o.my)")
print(io, UnicodePlots.spy(reverse(o.z, dims=1)).graphics)
end

Expand Down
17 changes: 8 additions & 9 deletions src/kernels.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
module Kernels
in_range(u) = abs(u) 1

biweight(u) = in_range(u) ? (1.0 - u ^ 2) ^ 2 : 0.0
cosine(u) = in_range(u) ? cos(0.5 * π * u) : 0.0
epanechnikov(u) = in_range(u) ? 1.0 - u ^ 2 : 0.0
triangular(u) = in_range(u) ? 1.0 - abs(u) : 0.0
tricube(u) = in_range(u) ? (1.0 - abs(u) ^ 3) ^ 3 : 0.0
triweight(u) = in_range(u) ? (1.0 - u ^ 2) ^ 3 : 0.0
uniform(u) = in_range(u) ? 0.5 : 0.0
biweight(u) = abs(u) 1 ? (1.0 - u ^ 2) ^ 2 : 0.0
cosine(u) = abs(u) 1 ? cos(0.5 * π * u) : 0.0
epanechnikov(u) = abs(u) 1 ? 1.0 - u ^ 2 : 0.0
triangular(u) = abs(u) 1 ? 1.0 - abs(u) : 0.0
tricube(u) = abs(u) 1 ? (1.0 - abs(u) ^ 3) ^ 3 : 0.0
triweight(u) = abs(u) 1 ? (1.0 - u ^ 2) ^ 3 : 0.0
uniform(u) = abs(u) 1 ? 0.5 : 0.0

# Kernels that don't require -1 ≤ u ≤ 1.
gaussian(u) = exp(-0.5 * u ^ 2)
logistic(u) = 1.0 / (exp(u) + 2.0 + exp(-u))
end
8 changes: 4 additions & 4 deletions src/univariate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ end
function Base.show(io::IO, ::MIME"text/plain", o::Ash)
println(io, "Ash")
f, l, s = round.((first(o.rng), last(o.rng), step(o.rng)), digits=4)
println(io, " > edges | $f : $s : $l")
println(io, " > kernel | $(o.kernel)")
println(io, " > m | $(o.m)")
println(io, " > nobs | $(o.nobs)")
println(io, " edges | $f : $s : $l")
println(io, " kernel | $(o.kernel)")
println(io, " m | $(o.m)")
println(io, " nobs | $(o.nobs)")
x, y = xy(o)
inds = findall(x -> x != 0, y)
print(io, UnicodePlots.lineplot(x[inds], y[inds]; grid = false))
Expand Down

0 comments on commit bece9cb

Please sign in to comment.