class_docstr: Compute the Fast Low-cost Online Semantic Segmentation (FLOSS) for
  streaming data
  
  Parameters
  ----------
  mp : numpy.ndarray
      The first column consists of the matrix profile, the second column
      consists of the matrix profile indices, the third column consists of
      the left matrix profile indices, and the fourth column consists of
      the right matrix profile indices.
  
  T : numpy.ndarray
      A 1-D time series data used to generate the matrix profile and matrix profile
      indices found in `mp`. Note that the the right matrix profile index is used and
      the right matrix profile is intelligently recomputed on the fly from `T` instead
      of using the bidirectional matrix profile.
  
  m : int
      The window size for computing sliding window mass. This is identical
      to the window size used in the matrix profile calculation. For managing
      edge effects, see the `L` parameter.
  
  L : int
      The subsequence length that is set roughly to be one period length.
      This is likely to be the same value as the window size, `m`, used
      to compute the matrix profile and matrix profile index but it can
      be different since this is only used to manage edge effects
      and has no bearing on any of the IAC or CAC core calculations.
  
  excl_factor : int, default 5
      The multiplying factor for the regime exclusion zone. Note that this
      is unrelated to the `excl_zone` used in to compute the matrix profile.
  
  n_iter : int, default 1000
      Number of iterations to average over when determining the parameters for
      the IAC beta distribution
  
  n_samples : int, default 1000
      Number of distribution samples to draw during each iteration when
      computing the IAC
  
  custom_iac : numpy.ndarray, default None
      A custom idealized arc curve (IAC) that will used for correcting the
      arc curve
  
  normalize : bool, default True
      When set to `True`, this z-normalizes subsequences prior to computing distances
  
  p : float, default 2.0
      The p-norm to apply for computing the Minkowski distance. Minkowski distance is
      typically used with `p` being 1 or 2, which correspond to the Manhattan distance
      and the Euclidean distance, respectively. This parameter is ignored when
      `normalize == True`.
  
  T_subseq_isconstant_func : function, default None
      A custom, user-defined function that returns a boolean array that indicates
      whether a subsequence in `T` is constant (True). The function must only take
      two arguments, `a`, a 1-D array, and `w`, the window size, while additional
      arguments may be specified by currying the user-defined function using
      `functools.partial`. Any subsequence with at least one np.nan/np.inf will
      automatically have its corresponding value set to False in this boolean array.
  
  Attributes
  ----------
  cac_1d_ : numpy.ndarray
      A 1-dimensional corrected arc curve (CAC) updated as a result of ingressing a
      single new data point and egressing a single old data point.
  
  P_ : numpy.ndarray
      The matrix profile updated as a result of ingressing a single new data
      point and egressing a single old data point.
  
  I_ : numpy.ndarray
      The (right) matrix profile indices updated as a result of ingressing a single
      new data point and egressing a single old data point.
  
  T_ : numpy.ndarray
      The updated time series, `T`
  
  Methods
  -------
  update(t)
      Ingress a new data point, `t`, onto the time series, `T`, followed by egressing
      the oldest single data point from `T`. Then, update the 1-dimensional corrected
      arc curve (CAC_1D) and the matrix profile.
  
  See Also
  --------
  stumpy.fluss : Compute the Fast Low-cost Unipotent Semantic Segmentation (FLUSS)
      for static data (i.e., batch processing)
  
  Notes
  -----
  `DOI: 10.1109/ICDM.2017.21 <https://www.cs.ucr.edu/~eamonn/Segmentation_ICDM.pdf>`__
  
  See Section C
  
  This is the implementation for Fast Low-cost Online Semantic
  Segmentation (FLOSS).
  
  Examples
  --------
  >>> import stumpy
  >>> import numpy as np
  >>> mp = stumpy.stump(np.array([584., -11., 23., 79., 1001., 0.]), m=3)
  >>> stream = stumpy.floss(
  ...     mp,
  ...     np.array([584., -11., 23., 79., 1001., 0.]),
  ...     m=3,
  ...     L=3)
  >>> stream.update(19.)
  >>> stream.cac_1d_
  array([1., 1., 1., 1.])
docstr: Initialize the FLOSS object
  
  Parameters
  ----------
  mp : numpy.ndarray
      The first column consists of the matrix profile, the second column
      consists of the matrix profile indices, the third column consists of
      the left matrix profile indices, and the fourth column consists of
      the right matrix profile indices.
  
  T : numpy.ndarray
      A 1-D time series data used to generate the matrix profile and matrix
      profile indices found in `mp`. Note that the the right matrix profile index
      is used and the right matrix profile is intelligently recomputed on-the-fly
      from `T` instead of using the bidirectional matrix profile.
  
  m : int
      The window size for computing sliding window mass. This is identical
      to the window size used in the matrix profile calculation. For managing
      edge effects, see the `L` parameter.
  
  L : int
      The subsequence length that is set roughly to be one period length.
      This is likely to be the same value as the window size, `m`, used
      to compute the matrix profile and matrix profile index but it can
      be different since this is only used to manage edge effects
      and has no bearing on any of the IAC or CAC core calculations.
  
  excl_factor : int, default 5
      The multiplying factor for the regime exclusion zone. Note that this
      is unrelated to the `excl_zone` used in to compute the matrix profile.
  
  n_iter : int, default 1000
      Number of iterations to average over when determining the parameters for
      the IAC beta distribution
  
  n_samples : int, default 1000
      Number of distribution samples to draw during each iteration when
      computing the IAC
  
  custom_iac : numpy.ndarray, default None
      A custom idealized arc curve (IAC) that will used for correcting the
      arc curve
  
  normalize : bool, default True
      When set to `True`, this z-normalizes subsequences prior to computing
      distances
  
  p : float, default 2.0
      The p-norm to apply for computing the Minkowski distance. Minkowski distance
      is typically used with `p` being 1 or 2, which correspond to the Manhattan
      distance and the Euclidean distance, respectively.This parameter is ignored
      when `normalize == True`.
  
  T_subseq_isconstant_func : function, default None
      A custom, user-defined function that returns a boolean array that indicates
      whether a subsequence in `T` is constant (True). The function must only take
      two arguments, `a`, a 1-D array, and `w`, the window size, while additional
      arguments may be specified by currying the user-defined function using
      `functools.partial`. Any subsequence with at least one np.nan/np.inf will
      automatically have its corresponding value set to False in this boolean
      array.
docstr_tok: ["Initialize","the","FLOSS","object","Parameters","--","--","--","--","--","mp",":","numpy.ndarray","The","first","column","consists","of","the","matrix","profile",",","the","second","column","consists","of","the","matrix","profile","indices",",","the","third","column","consists","of","the","left","matrix","profile","indices",",","and","the","fourth","column","consists","of","the","right","matrix","profile","indices",".","T",":","numpy.ndarray","A","1-D","time","series","data","used","to","generate","the","matrix","profile","and","matrix","profile","indices","found","in","`","mp","`",".","Note","that","the","the","right","matrix","profile","index","is","used","and","the","right","matrix","profile","is","intelligently","recomputed","on-the-fly","from","`","T","`","instead","of","using","the","bidirectional","matrix","profile",".","m",":","int","The","window","size","for","computing","sliding","window","mass",".","This","is","identical","to","the","window","size","used","in","the","matrix","profile","calculation",".","For","managing","edge","effects",",","see","the","`","L","`","parameter",".","L",":","int","The","subsequence","length","that","is","set","roughly","to","be","one","period","length",".","This","is","likely","to","be","the","same","value","as","the","window","size",",","`","m","`",",","used","to","compute","the","matrix","profile","and","matrix","profile","index","but","it","can","be","different","since","this","is","only","used","to","manage","edge","effects","and","has","no","bearing","on","any","of","the","IAC","or","CAC","core","calculations",".","excl_factor",":","int",",","default","5","The","multiplying","factor","for","the","regime","exclusion","zone",".","Note","that","this","is","unrelated","to","the","`","excl_zone","`","used","in","to","compute","the","matrix","profile",".","n_iter",":","int",",","default","1000","Number","of","iterations","to","average","over","when","determining","the","parameters","for","the","IAC","beta","distribution","n_samples",":","int",",","default","1000","Number","of","distribution","samples","to","draw","during","each","iteration","when","computing","the","IAC","custom_iac",":","numpy.ndarray",",","default","None","A","custom","idealized","arc","curve","(","IAC",")","that","will","used","for","correcting","the","arc","curve","normalize",":","bool",",","default","True","When","set","to","`","True","`",",","this","z-normalizes","subsequences","prior","to","computing","distances","p",":","float",",","default","2.0","The","p-norm","to","apply","for","computing","the","Minkowski","distance",".","Minkowski","distance","is","typically","used","with","`","p","`","being","1","or","2",",","which","correspond","to","the","Manhattan","distance","and","the","Euclidean","distance",",","respectively.This","parameter","is","ignored","when","`","normalize","==","True","`",".","T_subseq_isconstant_func",":","function",",","default","None","A","custom",",","user-defined","function","that","returns","a","boolean","array","that","indicates","whether","a","subsequence","in","`","T","`","is","constant","(","True",")",".","The","function","must","only","take","two","arguments",",","`","a","`",",","a","1-D","array",",","and","`","w","`",",","the","window","size",",","while","additional","arguments","may","be","specified","by","currying","the","user-defined","function","using","`","functools.partial","`",".","Any","subsequence","with","at","least","one","np.nan\/np.inf","will","automatically","have","its","corresponding","value","set","to","False","in","this","boolean","array","."]
code: def __init__(
      self,
      mp,
      T,
      m,
      L,
      excl_factor=5,
      n_iter=1000,
      n_samples=1000,
      custom_iac=None,
      normalize=True,
      p=2.0,
      T_subseq_isconstant_func=None,
  ):
      """
      Initialize the FLOSS object
  
      Parameters
      ----------
      mp : numpy.ndarray
          The first column consists of the matrix profile, the second column
          consists of the matrix profile indices, the third column consists of
          the left matrix profile indices, and the fourth column consists of
          the right matrix profile indices.
  
      T : numpy.ndarray
          A 1-D time series data used to generate the matrix profile and matrix
          profile indices found in `mp`. Note that the the right matrix profile index
          is used and the right matrix profile is intelligently recomputed on-the-fly
          from `T` instead of using the bidirectional matrix profile.
  
      m : int
          The window size for computing sliding window mass. This is identical
          to the window size used in the matrix profile calculation. For managing
          edge effects, see the `L` parameter.
  
      L : int
          The subsequence length that is set roughly to be one period length.
          This is likely to be the same value as the window size, `m`, used
          to compute the matrix profile and matrix profile index but it can
          be different since this is only used to manage edge effects
          and has no bearing on any of the IAC or CAC core calculations.
  
      excl_factor : int, default 5
          The multiplying factor for the regime exclusion zone. Note that this
          is unrelated to the `excl_zone` used in to compute the matrix profile.
  
      n_iter : int, default 1000
          Number of iterations to average over when determining the parameters for
          the IAC beta distribution
  
      n_samples : int, default 1000
          Number of distribution samples to draw during each iteration when
          computing the IAC
  
      custom_iac : numpy.ndarray, default None
          A custom idealized arc curve (IAC) that will used for correcting the
          arc curve
  
      normalize : bool, default True
          When set to `True`, this z-normalizes subsequences prior to computing
          distances
  
      p : float, default 2.0
          The p-norm to apply for computing the Minkowski distance. Minkowski distance
          is typically used with `p` being 1 or 2, which correspond to the Manhattan
          distance and the Euclidean distance, respectively.This parameter is ignored
          when `normalize == True`.
  
      T_subseq_isconstant_func : function, default None
          A custom, user-defined function that returns a boolean array that indicates
          whether a subsequence in `T` is constant (True). The function must only take
          two arguments, `a`, a 1-D array, and `w`, the window size, while additional
          arguments may be specified by currying the user-defined function using
          `functools.partial`. Any subsequence with at least one np.nan/np.inf will
          automatically have its corresponding value set to False in this boolean
          array.
      """
      self._mp = copy.deepcopy(np.asarray(mp))
      self._T = copy.deepcopy(np.asarray(T))
      self._m = m
      self._L = L
      self._excl_factor = excl_factor
      self._n_iter = n_iter
      self._n_samples = n_samples
      self._custom_iac = custom_iac
      self._normalize = normalize
      self._p = p
      self._T_subseq_isconstant = None
      self._M_T = None
      self._Σ_T = None
  
      if T_subseq_isconstant_func is None:
          T_subseq_isconstant_func = core._rolling_isconstant
      if not callable(T_subseq_isconstant_func):  # pragma: no cover
          msg = (
              "`T_subseq_isconstant_func` was expected to be a callable function "
              + f"but {type(T_subseq_isconstant_func)} was found."
          )
          raise ValueError(msg)
      self._T_subseq_isconstant_func = T_subseq_isconstant_func
  
      self._k = self._mp.shape[0]
      self._n = self._T.shape[0]
      self._last_idx = (
          self._n - self._m + 1
      )  # Depends on the changing length of `T`
      self._n_appended = 0
      self._T_isfinite = np.isfinite(self._T)
      self._finite_T = self._T.copy()
      self._finite_T[~np.isfinite(self._finite_T)] = 0.0
      self._finite_Q = self._finite_T[-self._m :].copy()
  
      if self._normalize:
          self._T_subseq_isconstant = core.process_isconstant(
              self._T, self._m, self._T_subseq_isconstant_func
          )
          self._M_T, self._Σ_T = core.compute_mean_std(self._T, self._m)
  
      if self._custom_iac is None:  # pragma: no cover
          self._custom_iac = _iac(
              self._k,
              bidirectional=False,
              n_iter=self._n_iter,
              n_samples=self._n_samples,
          )
  
      right_nn = np.zeros((self._k, self._m), dtype=np.float64)
  
      # Disable the bidirectional matrix profile indices and left indices
      self._mp[:, 1] = -1
      self._mp[:, 2] = -1
  
      # Update matrix profile distance to be right mp distance and not bidirectional.
      # Use right indices to perform direct distance calculations
      # Note that any -1 indices must have a np.inf matrix profile value
      right_indices = [
          np.arange(IR, IR + self._m, dtype=np.int64)
          for IR in self._mp[:, 3].tolist()
      ]
      right_nn[:] = self._T[np.array(right_indices)]
      if self._normalize:
          self._mp[:, 0] = np.linalg.norm(
              core.z_norm(core.rolling_window(self._T, self._m), 1)
              - core.z_norm(right_nn, 1),
              axis=1,
          )
          nn_subseq_isconstant = self._T_subseq_isconstant[
              self._mp[:, 3].astype(np.int64)
          ]
          # subseq and its nn are both constant
          mask = self._T_subseq_isconstant & nn_subseq_isconstant
          self._mp[mask, 0] = 0
  
          # Only the subseq OR its nn is constant but not both
          mask = np.logical_xor(
              self._T_subseq_isconstant, nn_subseq_isconstant
          )
          self._mp[mask, 0] = np.sqrt(m)
  
      else:
          self._mp[:, 0] = np.linalg.norm(
              core.rolling_window(self._T, self._m) - right_nn,
              axis=1,
              ord=self._p,
          )
      # Note that a negative matrix profile index (e.g. -1) represents a null index.
      # However, in numpy, negative indices are interpreted as counting from the end
      # of the array. To resolve this, we temporarily replace a negative index with
      # a self index. So, if subsequence S_i has no valid right nearest neighbor, then
      # self._mp[i, 3] will be set to i and its corresponding matrix profile distance
      # is set to 0.0. This temporary resolution is later resolved (by setting them
      # back to -1 and np.inf, respectively) in a post-processing step.
      inf_indices = np.argwhere(self._mp[:, 3] < 0).flatten()
      self._mp[inf_indices, 0] = np.inf
      self._mp[inf_indices, 3] = inf_indices
  
      self._cac = np.ones(self._k, dtype=np.float64) * -1
  
file_path: stumpy/stumpy/floss.py
imports: import copy
  import numpy
  import scipy.stats
  from .None import config, core
label_desc: Use image node_id 1 to create a new floss object  with example: obj = floss(mp, T, m, L, excl_factor, n_iter, n_samples, custom_iac, normalize, p, T_subseq_isconstant_func)