from random import random
import numpy as np
from algorithm import algorithm
import json


class white_noise(algorithm):
    def __init__(self):
        self.config_dict_ = None
        self.config_ = None
        self.standard_deviation_base_ = 0.0

    def set_config(self, config):
        self.config_ = config
        self.config_dict_ = json.loads(self.config_)
        self.standard_deviation_base_ = self.config_dict_["WHITE_NOISE_STANDARD_DEVIATION_BASE"]

    def config(self):
        return self.config_

    def eval(self, value):
        return value + np.random.normal(loc=0.0, scale=self.standard_deviation_base_, size=None)
