FIX #3503: use linalg.pinv to better deal with singular input data