...

/

Exercise: Plotting the Sigmoid Function

Exercise: Plotting the Sigmoid Function

Learn how to define a sigmoid function, then create a plot of the sigmoid and examine its relationship to the exponential function.

Defining a function for the sigmoid

In this exercise, we will use X_exp and Y_exp, created previously, to make a plot of what the exponential function looks like over the interval [-4, 4]. Then we will define a function for the sigmoid, create a plot of that, and consider how it is related to the exponential function. Perform the following steps to complete the exercise:

  1. Use this code to plot the exponential function:

    plt.plot(X_exp, Y_exp) 
    plt.title('Plot of $e^X$')
    

    The plot should look like this:

Press + to interact
Plotting the exponential function
Plotting the exponential function

Notice that in titling the plot, we’ve taken advantage of a kind of syntax called LaTeX, which enables the formatting of mathematical notation. We won’t go into the details of LaTeX here, but suffice to say that it is very flexible. Note that enclosing part of the title string in dollar signs causes it to be rendered using LaTeX, and that superscript can be created using ^.

Also note in the figure above that many points spaced close together create the appearance of a smooth curve, but in fact, it is a graph of discrete points connected by line segments.

What can we observe about the exponential function?

It is never negative: as XX ...

Access this course and 1400+ top-rated courses and projects.