Code: GitHub
52: 2017-09-30: Rank 681/2615, 8 points;
- (686. Repeated String Match ): 0:54:04, 2 error;
- (687. Longest Univalue Path ): 1:19:55, 3 error;
I was asked to help accelerate a classmate’s code of Simulated Annealing. In his code, the likelihood function is at first as follows:
def intensity(miu, alpha, beta, t, N):
return sum(alpha*np.exp(-beta*(range(t-1, 0, -1)))*N[0:t-1])+miu
def likelihood(miu, alpha, beta, T, N, n):
N = np.array(N)
n = np.array(N)
L1 = np.array([intensity(miu, alpha, beta, i+1, N) for i in range(T)])
L = sum(np.log(L1)*n[0:T])-sum(L1)