def initialize_with_standard_model(self, standard_model):
        """
        Initialize with a standard Hawkes model. Typically this will have
        been fit by gradient descent or BFGS, and we just want to copy
        over the parameters to get a good starting point for MCMC or VB.
        :param W:
        :param g:
        :return:
        """
        K = self.K
        from pyhawkes.standard_models import StandardHawkesProcess
        assert isinstance(standard_model, StandardHawkesProcess)
        assert standard_model.K == K

        # lambda0 = standard_model.weights[:,0]
        lambda0 = standard_model.bias

        # Get the connection weights
        W = np.clip(standard_model.W, 1e-16, np.inf)

        # Get the impulse response parameters
        G = standard_model.G
        t_basis = standard_model.basis.dt * np.arange(standard_model.basis.L)
        t_basis = np.clip(t_basis, 1e-6, self.dt_max-1e-6)
        for k1 in xrange(K):
            for k2 in xrange(K):
                std_ir = standard_model.basis.basis.dot(G[k1,k2,:])

                def loss(mutau):
                    self.impulse_model.mu[k1,k2] = mutau[0]
                    self.impulse_model.tau[k1,k2] = mutau[1]
                    ct_ir = self.impulse_model.impulse(t_basis, k1, k2)

                    return ct_ir - std_ir

                from scipy.optimize import leastsq
                mutau0 = np.array([self.impulse_model.mu[k1,k2],
                                   self.impulse_model.tau[k1,k2]])

                mutau, _ = leastsq(loss, mutau0)
                self.impulse_model.mu[k1,k2] = mutau[0]
                self.impulse_model.tau[k1,k2] = mutau[1]

        # We need to decide how to set A.
        # The simplest is to initialize it to all ones, but
        # A = np.ones((self.K, self.K))
        # Alternatively, we can start with a sparse matrix
        # of only strong connections. What sparsity? How about the
        # mean under the network model
        # sparsity = self.network.tau1 / (self.network.tau0 + self.network.tau1)
        sparsity = self.network.p
        A = W > np.percentile(W, (1.0 - sparsity) * 100)

        # Set the model parameters
        self.bias_model.lambda0 = lambda0.copy('C')
        self.weight_model.A     = A.copy('C')
        self.weight_model.W     = W.copy('C')
dataset/ETHPy150Open slinderman/pyhawkes/pyhawkes/models.py/ContinuousTimeNetworkHawkesModel.initialize_with_standard_model/original