Skip to content

Instantly share code, notes, and snippets.

@luisfredgs
Last active May 23, 2020 17:04
Show Gist options
  • Save luisfredgs/31d03fabc5213e3fd08a52f549c309c0 to your computer and use it in GitHub Desktop.
Save luisfredgs/31d03fabc5213e3fd08a52f549c309c0 to your computer and use it in GitHub Desktop.
Plot sigmoid using R
library(ggplot2)
library(dplyr)
sigmoid = function(x) {
1 / (1 + exp(-x))
}
###
vals <- tibble(x = seq(-10, 10, 1),
sigmoid_x=sigmoid(seq(-10,10,1)))
p <- ggplot(vals, aes(x, sigmoid_x))
p <- p + geom_point(colour='#F1948A', size=4)
p <- p + theme_linedraw()
p + stat_function(fun = sigmoid, n = 1000)
@luisfredgs
Copy link
Author

Rplot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment