fixed some bugs in density-ratio algorithm