rewriten entropy() in C, used nested  with buffer size of 100 to improve memory usage.