import matplotlib.pyplot as plt
import numpy as np


def sigmoid(x, w=0, b=0):
    return 1 / (1 + (np.exp( - (w*x + b))))


# Experiment with different values of w
# The slope of the curve gets steep
########################################################################################################
for w in range(6, 100):

    x = np.linspace(-1, 1, 256)

    y = []

    for each_x in x:
        y.append(sigmoid(each_x, w, b = 0))

    fig = plt.figure()

    fig.set_size_inches(8,6)

    ax = plt.subplot(111)
    ax.plot(x, y)

    # Hide the right and top spines
    ax.spines['right'].set_visible(False)
    ax.spines['top'].set_visible(False)

    plt.xlim(-1, 1)
    plt.ylim(0, 1)

    plt.plot(x, y, linewidth=2, color='red')

    start, end = ax.get_xlim()
    ax.xaxis.set_ticks(np.arange(start, end+.5, 0.5))

    ax.tick_params(direction="in")

    for tick in ax.xaxis.get_major_ticks():
        tick.label.set_fontsize(10)

    plt.savefig('sig_2d/a_' + str(w) + '.jpg', dpi=100)
#     plt.show()


# Experiment with different values of b
# The curve shifts towards left
########################################################################################################

for b in range(1, 40):

    w = 50

    x = np.linspace(-1, 1, 256)

    y = []

    for each_x in x:
        y.append(sigmoid(each_x, w, b))

    fig = plt.figure()
    fig.set_size_inches(8,6)

    ax = plt.subplot(111)
    ax.plot(x, y)

    # Hide the right and top spines
    ax.spines['right'].set_visible(False)
    ax.spines['top'].set_visible(False)

    plt.xlim(-1, 1)
    plt.ylim(0, 1)

    plt.plot(x, y, linewidth=2, color='red')

    start, end = ax.get_xlim()
    ax.xaxis.set_ticks(np.arange(start, end+.5, 0.5))

    ax.tick_params(direction="in")

    for tick in ax.xaxis.get_major_ticks():
        tick.label.set_fontsize(10)

    plt.savefig('sig_2d/b_' + str(b) + '.jpg', dpi=100)
#     plt.show()
