Made the following changes
1. Fix condition for checking threshold.
2. Fix the global clustering by remapping the samples to the
   subcluster_centers.
3. Add tests for threshold.
4. Minor doc and cosmits.