Esempio n. 1
0
    def __init__(self, adjacency, decays, baseline=None,
                 end_time=None, max_jumps=None, seed=None, verbose=True,
                 force_simulation=False):

        if isinstance(adjacency, list):
            adjacency = np.array(adjacency)

        if isinstance(decays, list):
            decays = np.array(decays)

        n_nodes = adjacency.shape[0]

        if adjacency.shape != (n_nodes, n_nodes):
            raise ValueError("adjacency matrix should be squared and its "
                             "shape is %s" % str(adjacency.shape))

        decays_is_number = isinstance(decays, (int, float))
        if not decays_is_number and decays.shape != (n_nodes, n_nodes):
            raise ValueError("decays should be either a float or an array of "
                             "shape %s but its shape is %s"
                             % (str((n_nodes, n_nodes)),
                                str(decays.shape)))

        self.adjacency = adjacency
        self.decays = decays

        kernels = self._build_exp_kernels()

        SimuHawkes.__init__(self, kernels=kernels, baseline=baseline,
                            end_time=end_time, max_jumps=max_jumps,
                            seed=seed, verbose=verbose,
                            force_simulation=force_simulation)
Esempio n. 2
0
    def __init__(self, adjacency, decays, baseline=None,
                 end_time=None, period_length=None, max_jumps=None,
                 seed=None, verbose=True,
                 force_simulation=False):

        if isinstance(adjacency, list):
            adjacency = np.array(adjacency)

        if isinstance(decays, list):
            decays = np.array(decays)

        n_nodes = adjacency.shape[0]
        n_decays = decays.shape[0]

        if adjacency.shape != (n_nodes, n_nodes, n_decays):
            raise ValueError("adjacency matrix shape should be %s but its "
                             "shape is %s" % (str((n_nodes, n_nodes, n_decays)),
                                              str(adjacency.shape)))

        self.adjacency = adjacency
        self.decays = decays

        kernels = self._build_sumexp_kernels()

        SimuHawkes.__init__(self, kernels=kernels, baseline=baseline,
                            end_time=end_time, period_length=period_length,
                            max_jumps=max_jumps, seed=seed, verbose=verbose,
                            force_simulation=force_simulation)