Skip to content

Instantly share code, notes, and snippets.

View tnarihi's full-sized avatar

Takuya Narihira tnarihi

  • Sony
  • Tokyo, Japan
View GitHub Profile
@tnarihi
tnarihi / numpy_tutorial.ipynb
Created March 4, 2014 13:07
日本語によるNumpyのチュートリアル的なもの。IPythonノートブックビューアで見てください。<http://nbviewer.ipython.org/gist/tnarihi/9346213>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# -*- coding: utf-8 -*-
import numpy as np
import pylab as pl
__author__ = 'Takuya Nairihira'
def compute_belonging(x, c):
dist_NxK = (x**2).sum(axis=1)[:,np.newaxis] - 2. * np.dot(x, c.T) + (c**2).sum(axis=1)[np.newaxis]
return dist_NxK.argmin(axis=1)