import random


def mutate(x, mutation_rate=1):
    """
    Mutate a random gene
    :param x: individual to mute (numpy vector)
    :param mutation_rate: increasing/decreasing factor
    :return: mutated x (numpy vector)
    """
    mut_gene = random.randint(1, len(x) - 2)
    x[mut_gene] += (mutation_rate if random.randint(0, 1) == 0 else -mutation_rate)
    return x