code: def STOMPDistanceProfile(tsA, idx, m, tsB, dot_first, dp, mean, std):
      """
      Returns the distance profile of a query within tsA against the time series tsB using the even more efficient iterative STOMP calculation. Note that the method requires a pre-calculated 'initial' sliding dot product.
  
      Parameters
      ----------
      tsA: Time series containing the query for which to calculate the distance profile.
      idx: Starting location of the query within tsA
      m: Length of query.
      tsB: Time series to compare the query against. Note that, for the time being, only tsB = tsA is allowed
      dot_first: The 'initial' sliding dot product, or QT(1,1) in Zhu et.al
      dp: The dot product between tsA and the query starting at index m-1
      mean: Array containing the mean of every subsequence of length m in tsA (moving window)
      std: Array containing the mean of every subsequence of length m in tsA (moving window)
      """
  
      selfJoin = is_self_join(tsA, tsB)
      if selfJoin:
          tsB = tsA
  
      query = tsA[idx : (idx + m)]
      n = len(tsB)
  
      # Calculate the first distance profile via MASS
      if idx == 0:
          distanceProfile = np.real(
              np.sqrt(mass(query, tsB).astype(complex))
          )
  
          # Currently re-calculating the dot product separately as opposed to updating all of the mass function...
          dot = slidingDotProduct(query, tsB)
  
      # Calculate all subsequent distance profiles using the STOMP dot product shortcut
      else:
          res, dot = massStomp(
              query, tsB, dot_first, dp, idx, mean, std
          )
          distanceProfile = np.real(np.sqrt(res.astype(complex)))
  
      if selfJoin:
          trivialMatchRange = (
              int(max(0, idx - np.round(m / 2, 0))),
              int(min(idx + np.round(m / 2 + 1, 0), n)),
          )
          distanceProfile[
              trivialMatchRange[0] : trivialMatchRange[1]
          ] = np.inf
  
      # Both the distance profile and corresponding matrix profile index (which should just have the current index)
      return (
          distanceProfile,
          np.full(n - m + 1, idx, dtype=float),
      ), dot
  
file_path: matrixprofile-ts/matrixprofile/distanceProfile.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  from .utils import *
  import numpy
label_desc: Use image node_id 4 for calling a global function with example usage: STOMPDistanceProfile(tsA, idx, m, tsB, dot_first, dp, mean, std) and returns: distanceProfile,  np,  dot