Calculate nonzero vector from test data