performance tuning:
1. avoid hash lookup when calculating derivatives and likelihood.
2. adjust storage type of XSampleType