import numpy as np

def sigmoid(x, prime=False):
    """Sigmoid activation function. Ranges from 0 ~ 1
    Note that if prime is set to True, then the function should be
    called like my_activation(my_activation(x), prime=True). This 
    is due to the convenience during back-prop.

    Args:
        x (np.ndarray): Input matrix
        prime (bool, optional): Compute derivative if True. Defaults to False.

    Returns:
        np.ndarray: Output data
    """    
    if prime:
        return np.multiply(x, 1 - x)
    return 1 / (1 + np.exp(-x))