Example #1
0
def deleter(Hawkes):
    k = 1
    Hawkes.propogate_by_amount(10)
    while (Hawkes.density(Hawkes.Events[-1]) < 100) and (k < 100):
        Hawkes.propogate_by_amount(10)
        k += 1
    return k
Example #2
0
def deleter(Hawkes, alpha, th):
    k = 1
    if (alpha*Hawkes.param[0]/Hawkes.param[1] < 1) and (not Hawkes.Nonlin(1) == np.exp(1)):
        Hawkes.propogate_by_amount(10)
        while Hawkes.Events[-1] < 500:
            Hawkes.propogate_by_amount(1)
    else: 
        Hawkes.propogate_by_amount(10)
        while (Hawkes.density(Hawkes.Events[-1]) < th) and (k < 100): 
            Hawkes.propogate_by_amount(10)
            k += 1
        return k
Example #3
0
def deleter(Hawkes, alpha, th):
    k = 1
    if alpha * Hawkes.param[0] * Hawkes.param[1] / 2 < 1:
        Hawkes.propogate_by_amount(10)
        while Hawkes.Events[-1] < 500:
            Hawkes.propogate_by_amount(1)
    else:
        Hawkes.propogate_by_amount(10)
        while (Hawkes.density(Hawkes.Events[-1]) < th) and (k < 1000):
            Hawkes.propogate_by_amount(10)
            k += 1
        return k
Example #4
0
def DataGenerator(inp):

    param = inp
    alpha = 1
    th = 50

    expl_proc = []
    count_1 = 0

    def deleter(Hawkes, alpha, th):
        k = 1
        if (alpha * Hawkes.param[0] / Hawkes.param[1] <
                1) and (not Hawkes.Nonlin(1) == np.exp(1)):
            Hawkes.propogate_by_amount(10)
            while Hawkes.Events[-1] < 100:
                Hawkes.propogate_by_amount(1)
        else:
            Hawkes.propogate_by_amount(10)
            while (Hawkes.density(Hawkes.Events[-1]) < th) and (k < 100):
                Hawkes.propogate_by_amount(10)
                k += 1
            return k

    def HawkesIntensity_temporal(time, params):
        Ind = (time >= 0)
        return params[0] * np.exp(-params[1] * time) * Ind

    for i in range(100):
        print('Für Parameter ({},{}) count_nr: {}'.format(
            param[0], param[1], count_1))
        H = Hawkes(HawkesIntensity_temporal,
                   param,
                   phi=lambda s: (1 + s)**2 / (2 + s),
                   mon_kernel=True)
        deleter(H, alpha, th)
        if (H.density(H.Events[-1]) >=
                th):  #or (alpha*H.param[0]/H.param[1] < 1):
            vars()['H_' + str(count_1)] = H
            expl_proc.append('H_' + str(count_1))
            count_1 += 1

    return count_1
Example #5
0
    return params[0]*np.exp(-params[1]*time)*Ind



# alpha gives boundry of stability given by theorems by bremaud & masoulie
param = [1/4,5]
alpha = 1/2
th = 100


expl_proc = []
count_1 = 0

for i in range(1000):
    print(count_1)
    H = Hawkes(HawkesIntensity_temporal, param, phi = lambda s: np.exp(s), mon_kernel = True)
    deleter(H, alpha, th)
    if (H.density(H.Events[-1]) >= th) or (alpha*H.param[0]/H.param[1] < 1):     
        vars()['H_' + str(count_1)] = H
        expl_proc.append('H_' + str(count_1))
        count_1 += 1



for item in expl_proc:
    vars()['dense_' + item] = []
    t = np.linspace(0,vars()[item].Events[-1],1000)
    for i in t:
        vars()['dense_' + item].append(vars()[item].density(i))
    plt.plot(t,vars()['dense_' + item])
Example #6
0
def HawkesIntensity_temporal(time, params):
    Ind = (time >= 0)
    return params[0] * np.exp(-params[1] * time) * Ind


# alpha gives boundry of stability given by theorems by bremaud & masoulie
param = [2, 1]
alpha = 1
th = 100

expl_proc = []
count_1 = 0

for i in range(100):
    print(count_1)
    H = Hawkes(HawkesIntensity_temporal, param, mon_kernel=True)
    deleter(H, alpha, th)
    if (H.density(H.Events[-1]) >= th) or (alpha * H.param[0] / H.param[1] <
                                           1):
        vars()['H_' + str(count_1)] = H
        expl_proc.append('H_' + str(count_1))
        count_1 += 1

for item in expl_proc:
    vars()['dense_' + item] = []
    t = np.linspace(0, vars()[item].Events[-1], 1000)
    for i in t:
        vars()['dense_' + item].append(vars()[item].density(i))
    plt.plot(t, vars()['dense_' + item])

#plt.plot(t, 2*np.ones(len(t)), 'k')