ex6 and gaussian kernel implementation