Skip to content

Instantly share code, notes, and snippets.

@mcfrank
Created October 26, 2022 23:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcfrank/8d71e49520c70b87ebc59bae2ebf5c0e to your computer and use it in GitHub Desktop.
Save mcfrank/8d71e49520c70b87ebc59bae2ebf5c0e to your computer and use it in GitHub Desktop.
# delta rule formula
# (i-o) o (1-o)
library(tidyverse)
d <- expand_grid(i = seq(0.05,.95,.05),
o = seq(0.05,.95,.05)) |>
mutate(last_part = o * (1-o),
first_part = abs(i-o),
delta = abs((i-o) * o * (1-o)),
divergence = i * log(i/o))
d_wide <- d |>
pivot_longer(last_part:divergence, names_to = "measure", values_to = "value")
ggplot(d_wide, aes(x = i, y = value, col = o)) +
geom_line(aes(group = as.factor(o))) +
facet_wrap(~measure, scales = "free_y") +
ylab("curiosity") +
xlab("input value") +
viridis::scale_color_viridis(name = "output value")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment