def kmm_init(X, m = <NUM_LIT:10>):
<EOL>XXT = np.dot(X, X.T)<EOL>D = (-<NUM_LIT>*XXT + np.diag(XXT)[:,np.newaxis] + np.diag(XXT)[np.newaxis,:])<EOL>s = np.random.permutation(X.shape[<NUM_LIT:0>])[<NUM_LIT:0>]<EOL>inducing = [s]<EOL>prob = D[s]/D[s].sum()<EOL>for z in range(m-<NUM_LIT:1>):<EOL><INDENT>s = np.random.multinomial(<NUM_LIT:1>, prob.flatten()).argmax()<EOL>inducing.append(s)<EOL>prob = D[s]/D[s].sum()<EOL><DEDENT>inducing = np.array(inducing)<EOL>return X[inducing]<EOL>
This is the same initialization algorithm that is used
in Kmeans++. It's quite simple and very useful to initialize
the locations of the inducing points in sparse GPs.

:param X: data
:param m: number of inducing points