Exemplo n.º 1
0
def generate_jump_process(pp: Sequence[float], duration: int, jump_mean: float, rng: np.random.Generator, discount: float = 0.0):
    jp = []
    current_jump = 0
    for k in range(duration):
        jumps = [int(t) for t in pp if int(t) == k]
        for jump in jumps:
            current_jump += rng.exponential(jump_mean)
        jp += [current_jump]
        current_jump *= (1-discount)
    return np.array(jp)
Exemplo n.º 2
0
def generate_poisson_process(l: float, duration: float, rng: np.random.Generator) -> Sequence[float]:
    """
    Generates a Poisson arrival process of rate `l` and duration `duration`.
    """
    t = 0
    ia_times = []
    while t < duration:
        ia_time = rng.exponential(1.0 / l)
        t += ia_time
        ia_times += [t]
        
    return ia_times
Exemplo n.º 3
0
def apply_block_time_variance(demand_process: Sequence[float], blocks: int, mean_ia_time: float = 13, rng: np.random.Generator = rng) -> Sequence[int]:
    # Block time differences are distributed along a Poisson(13)
    ia_times = rng.exponential(13, blocks)
    demand_per_block = []
    current_time = 0
    for block_index, ia_time in enumerate(ia_times):
        ia_time = int(ia_time)
        new_demand = 0
        for t in range(current_time, current_time + ia_time):
            new_demand += demand_process[t]
        demand_per_block += [int(new_demand)]
        current_time += ia_time
    return demand_per_block