def idealfourths(data, axis=None):
 def _idf(data):
  x = data.compressed()
  n = len(x)
  if (n < 3):
   return [np.nan, np.nan]
  (j, h) = divmod(((n / 4.0) + (5 / 12.0)), 1)
  j = int(j)
  qlo = (((1 - h) * x[(j - 1)]) + (h * x[j]))
  k = (n - j)
  qup = (((1 - h) * x[k]) + (h * x[(k - 1)]))
  return [qlo, qup]
 data = ma.sort(data, axis=axis).view(MaskedArray)
 if (axis is None):
  return _idf(data)
 else:
  return ma.apply_along_axis(_idf, axis, data)

def idealfourths ( data , axis = None ) : def _idf ( data ) : x = data . compressed ( ) n = len ( x ) if ( n < 3 ) : return [ np . nan , np . nan ] ( j , h ) = divmod ( ( ( n / 4.0 ) + ( 5 / 12.0 ) ) , 1 ) j = int ( j ) qlo = ( ( ( 1 - h ) * x [ ( j - 1 ) ] ) + ( h * x [ j ] ) ) k = ( n - j ) qup = ( ( ( 1 - h ) * x [ k ] ) + ( h * x [ ( k - 1 ) ] ) ) return [ qlo , qup ] data = ma . sort ( data , axis = axis ) . view ( MaskedArray ) if ( axis is None ) : return _idf ( data ) else : return ma . apply_along_axis ( _idf , axis , data )
this function returns an estimate of the lower and upper quartiles of the data along the given axis .