ENH: move more calculation of the joint endpoint distribution into cython code, but it is not yet tested