Added some parameter validation and changed the program to make it dump the index and the related standard deviation of the related index.