Sunday, June 16, 2013

Global Silhouette Matlab

Whenever we cluster we should check the cluster quality but how can we do this ? One of the way to do that is to calculate it's Global Silhouette. It works pretty well for most clustering algorithms.

The basic idea behind global silhouette is what is the quality of separation between the points in one cluster to another cluster's points.

Below is the matlab code for it which uses silhouette() function from matlab .


If you need the code for silhouette or how to calculate s(i) for each data point e-mail me.

Tuesday, May 28, 2013

Matlab Examples

Here is a code for averaging a set of signals, note that my input is taken from a .wav file and thus is of different making it a little more code. This is for who got stuck and can't find a way out.Using the saved .jpeg files you can see how it works visually.



Friday, May 24, 2013

Douglas-Peucker Algorithm

An algorithm for smoothing a 2-d plot . You can read a good explanation of it at wikipedia Wiki Link . Following is the matlab code that I wrote for it:

Wednesday, February 27, 2013

SPOJ:Insertion Sort

The problem asks us to find the number of swaps an insertion sorts does, which in a way is a measure of efficiency of the sort.

The basic logic is answer is the sum of ( for each element the number of elements greater than itself occuring before it .)

One way to implement it is Employ merge sort on it and during each merge operations if you are copying an element from the right array (swaps +=no. of elements in the left array) .

A novice mistake which I made what that I dynamically allocating and de-allocating a temporary array during each merge operation, BEWARE this is a very costly operation and should not be used. Allocate memory once and pass that array .