matches according to the rulesto subtract over axis (that issubtract the row mean from each row)the smaller array must have shape ( )in [ ]arr out[ ]array([ - ] ][- ] - ]]in [ ]row_means arr mean( in [ ]row_means reshape(( )out[ ]array([ ] ] ] ]]in [ ]demeaned arr row_means reshape(( )in [ ]demeaned mean( out[ ]array( ]has your head exploded yetsee figure - for an illustration of this operation figure - broadcasting over axis of array see figure - for another illustrationthis time subtracting two-dimensional array from three-dimensional one across axis broadcasting over other axes broadcasting with higher dimensional arrays can seem even more mind-bendingbut it is really matter of following the rules if you don'tyou'll get an error like thisin [ ]arr arr mean( valueerror traceback (most recent call lastin ( advanced numpy www it-ebooks info