Fixed derivatives in histogram

(backported from master, see commit 92717cb65fc1b2a67be0adb01c635c6fce0a905f)
Fixed regtest

After 4525d50f4babf4db72acf0831c49055558ebac66
changelog
Merge branch 'v2.0' into v2.1
Merge branch 'v2.1'

Conflicts:
	src/tools/KernelFunctions.cpp

(dummy conflict, just a space at end of line)