text:
\section{Introduction}
Piecewise constant (PWC) signals are an important subclass of piecewise continuous data which occur in a variety of applications such as bioinformatics, astrophysics, geophysics, molecular biosciences and digital imagery \cite{Sowa2005, Little2010,Little2011,Little2011a,Nirody2017}.
Figure~\ref{fig:methodsOverview}a--c shows several forms of PWC signals both deterministic and stochastic.
The PWC waveform also occurs in the output of several sensors, which include tachometers.
Sensors with PWC waveform are widely used and implemented in applications that involve rotating machinery such as investigating pressure fluctuations in bearings \cite{Youssef2017}, flat plate motions \cite{Jin2016}, analyzing the powertrain vibrations of vehicles \cite{Albers2016}, and for the experimental investigations of the dynamic performance of wind turbines \cite{Rahman2016}.
One important example of PWC waveform sensors are laser tachometers which are often used in machining process applications, including monitoring rotation velocity in the presence of spindle speed modulation \cite{Urbikain2016} or vibration-assisted cutting in turning \cite{Amini2017}, defect detection for friction stir welding \cite{Das2016}, measuring the feed error in tapping processes \cite{Wan2017}, and for stroboscopic sampling of vibrations in milling \cite{Honeycutt2017}.

\begin{figure}[tbp]
	\centering
	\includegraphics[width=0.95\textwidth, draft = False]{methods_overview.png}
	\caption{An overview of the categorization (left column) and analysis (right column) of the type of signals considered in this study. The paper investigates piecewise constant signals with two-state trajectories and random digital ringing (panel b in the left figure).}
	\label{fig:methodsOverview}
\end{figure}

The output of laser tachometers assumes two logical levels low/high or on/off based on the reflectivity or contrast of the target material when subjected to a laser source.
These tachometers often output transistor-transistor-logic (TTL) pulses triggered by the change in the reflected laser beam.
The resulting two-state trajectory can be collected using digital or analog channels.
If analog channels are used to collect the laser tachometer signal, then noise will be superimposed on the pulse train.
Generally, utilizing linear filtering for noise removal from PWC signals is inefficient because both the noise and the PWC signal have a broad band frequency spectrum.
However, since for laser tachometers the signal to noise ratio is typically large the underlying digital signal can be recovered by hard-thresholding an adequately sampled time series.
However, hard-thresholding is not suitable in general for stochastic PWC signals such as the case shown in Fig.~\ref{fig:methodsOverview}c.

Assuming that a representative, noise-free sample of the laser tachometer signal has been recovered, another challenge is the phenomenon where spurious pulses appear in the signal near the transitions of reflective/non-reflective target, as shown in Fig.~\ref{fig:methodsOverview}b.
We call these peaks \textit{digital ringing}.
We observed these peaks while collecting laser tachometer signals during a turning experiment.
These spurious peaks can occur due to (1) chips or cooling fluid interrupting the laser beam in manufacturing applications, (2) vibrations of the laser tachometer holder near regions on the target with different contrast, (3) vibration of the target away or towards the laser tachometer, or (4) unintended reflections of the laser beam on non-target surfaces due to the motion of the machine.
These spurious peaks can occur at the rising or falling edges but they do not occur as a repetitive pattern, and they may not occur at some peaks or at all combinations of cutting parameters.
Hence, they are considered a random variable and are grouped under the umbrella of stochastic systems in Fig.~\ref{fig:methodsOverview}.
The challenge in obtaining the once-per-revolution pulse or in counting the number of pulses per unit time is exacerbated by these spurious peaks.
Moreover, significant complications are introduced if the spacing between the pulses is further randomly modulated either due to external disturbances or due to some noise superimposed on intentional, regular variations of the rotational speed.
In both these scenarios the interest is in finding either (a) the rising edge, (b) the peak, or (c) the falling edge where a true transition in the reflectivity of the target occurs.
In tachometer signals it is common to detect falling or rising edges, so in this study we choose to investigate the rising edges of true transitions.

While finding true peaks from a signal contaminated with noise may seem like an easy problem,
the existence of spurious peaks precludes using traditional, step detection methods for peak detection and counting.
For example, peak-finding algorithms are not useful here because true peaks can be incorrectly counted multiple times thus giving false counts and consequently yielding exaggerated spindle speeds.
In addition, setting width thresholds in the peaks algorithm requires the user to have a priori knowledge of the existing noise, which may not be feasible or practical.
The peak finding algorithm also catastrophically fails if the spacing between peaks randomly varies due, for example, to randomness in the spindle drive or variations in the cutting load of machine tools.
Further, since the signal is corrupted by digital ringing, typical filtering techniques for PWC signals \cite{Little2011,Little2011a} such as total variation denoising, hidden Markov chains, and wavelets are ineffective.
Traditional clustering methods such as $k$-means clustering require knowing the number of clusters desired in advance, and thus are not useful for our need to automatically count the number of pulses.

It is worth mentioning that identifying true peaks in the presence of digital ringing as described in this
paper is a task where humans outperform traditional computer algorithms.
However, while humans can often identify true peaks, counting them is prone to error particularly when the number of pulses is large per unit time.
Moreover, it is impractical to rely on human interpretation of laser tachometer signals especially in high-speed or real-time operations.

Therefore, the objective of this paper is to introduce a simple yet powerful approach for automatically detecting the true steps in a PWC two-state square wave subject to digital ringing.
The specific application is obtaining the spindle speed of a machine tool with a laser tachometer whose signal is corrupted by spurious on/off pulses.
We also extend the approach to the case where the spacing between the pulses varies randomly, and we discuss and extension of the theory to higher dimensional analogs, and
we derive mathematical guarantees for the resulting change detection which enables accurate identification and counting of the true pulses.
The approach we utilize is based on Topological Data Analysis (TDA) \cite{Ghrist2014,Edelsbrunner2010,Kaczynski2004,Zomorodi2005,Ghrist2008,Carlsson2009} and it is outlined in Section \ref{sec:method}.

The prevalence of Topological Data Analysis (TDA)  has exploded in recent years due to its use in many disparate domains.
Arguably the most prevalent application is that of TDA to time series analysis and signal processing, having spawned some of the earliest results in the field \cite{Robins1998,Robins2000a,Robins2004}.
This subfield of TDA is often referred to as Topological Signal Processing (TSP) \cite{Robinson2014}.
From the insights gained from the beginnings of TSP came one of the most prominent tools in TDA, namely persistent homology \cite{Edelsbrunner2002,Zomorodian2004}, which quantifies shape and structure in data.

Now, TSP has become a mature field in its own right.
Much of the work stems from utilizing persistent homology in conjunction with delay coordinate embeddings to give topological quantification of attractors of dynamical systems \cite{Garland2016,MacPherson2012,Alexander2015,Maletic2016,Pereira2015}.
Recent work has come in the form of classification and quantification of periodicity and quasi-periodicity \cite{Perea2016,Perea2014,Tralie2017,Robinson2015,deSilva2012}.
This work has appeared in a diverse array of applications including
wheeze detection \cite{Emrani2014},
computer performance \cite{Alexander2012a},
market prices \cite{Gidea2017,Gidea2017a},
sonar \cite{Robinson2013c},
image processing \cite{Vejdemo-Johansson2015},
ice core analysis \cite{Berwald2014a},
machining dynamics \cite{Khasawneh2015,Khasawneh2014,Khasawneh2014a,Khasawneh2017},
and gene expression \cite{Deckard2013,Perea2015}.

In this paper, we will utilize one of the simplest examples of persistent homology, namely 0-dimensional persistence defined on points in $\mathbb R$.
Viewing our data in this way gives access to the powerful theory built up for understanding persistent homology, particularly with respect to noise.
In particular, the existence of a metric on the space of persistence diagrams leads to the powerful notion of stability \cite{Cohen-Steiner2007,Cohen-Steiner2010}.
This knowledge in conjunction with our assumptions on noise is the theoretical basis for the algorithm we develop in Section \ref{sec:method}.
While there is a growing collection of ever faster code for computation of  persistent homology \cite{Otter2015}, our restricted setting also gives rise to simplified algorithms, thus making the analysis quite fast.
An additional perk of this viewpoint is that it also allows for generalization to higher dimensional problems as outlined in Section \ref{sec:Conclusions}\ref{ssec:higherDim}.

The approach is described and tested using both synthetic and experimental data.
The experimental apparatus includes an engine lathe instrumented with a laser tachometer which detects the change in reflectivity of a tape adhered to the circumference of the spindle.
The resulting mean spindle speed is then reported with appropriate error bounds.
We also compare the results to the output of Fourier analysis.
It is found that the described approach provides comparable results to Fourier for regular pulse waves with digital ringing; however, the numerical calculations show that the described approach outperforms Fourier analysis when the spacing between the pulses is varied.

\section{Background}
This section provides the necessary background for motivating and presenting the new approach for pulse counting using persistence diagrams.
Section \ref{sec:current_methods} discusses existing methods for pulse counting and spindle speed calculations. Sections \ref{sec:0dim_persistent}--\ref{sec:MST} present the background theory on persistent homology and describes how it relates to the current work.

\subsection{Current methods for counting and rotational speed calculation} \label{sec:current_methods}
Sensors for detecting rotary motion include proximity sensors, photoelectric sensors, and encoders.
These sensors output pulses that can be counted and used to find the speed of the shaft, typically, in units of revolutions per minute (RPM).
The pulse signals are piecewise continuous (PWC) functions with two logic levels: high or on, and low or off.
The quality of the output data depends on the number of pulses per revolution which affects the data resolution, as well as the symmetry of the pulses, which influences the accuracy and consistency of the data.

Once the pulses are obtained, there are generally two techniques for determining the corresponding RPM: 1) frequency measurement approach (calculate RPM from pulse count and pulse frequency), and 2) period measurement approach (calculate RPM from pulse count and pulse period).
The frequency approach involves transforming the signal into the frequency domain using a Fourier transform; however, the Fourier transform of a PWC signals can have slow convergence \cite{Stephane2009}.
Other counting algorithms include local maxima or peak detection with wavelet transforms or other methods \cite{Little2011}.
However, the interest in this study is in detecting true peaks, not all peaks.
Therefore, utilizing conventional methods for peak detection must be combined with a threshold for rejecting false peaks or retaining true ones.
It may be tempting to utilize a statistical measure such as the variance or standard deviation of the pulse duration.
However, since the data can vary from bimodal to uniform depending on the amount of noise introduced, statistical dispersion measures are generally not effective.

When there is noise superimposed on the signal (for example due to  collecting the signal on an analog channel) this noise can be removed by hard thresholding.
If the noise component is so large that the pulse structure can no longer be distinguished as shown in Fig.~\ref{fig:methodsOverview}c, the denoising becomes more difficult because the traditional approach of low-pass filtering typically introduces large spurious oscillations in PWC signals \cite{Stephane2009}.
In this case, either the viewpoint of piecewise constant smoothing, or that of level-set recovery can be used for determining the location of the jumps \cite{Little2011}.
In this paper, we focus on signals where the small amount of noise superimposed on the pulse amplitude can be removed by thresholding, but where spurious random pulses occur at the rising or falling edges and where the spacing between peaks can randomly vary.
This type of noise cannot be removed by thresholding, or by traditional filtering techniques.
Varying the period length between two consecutive pulses significantly complicates the analysis, and without a proper method for change detection can lead to poor RPM calculations.
Therefore, there is still a need for new, robust tools for pulse detection in PWC signals and this paper presents a method for reliable pulse-counting using 0-dimensional persistent homology.

\subsection{0-dimensional Persistent homology}
\label{sec:0dim_persistent}
Persistent homology \cite{Robins1998,Robins2000a,Edelsbrunner2002,Zomorodian2004}, a tool arising from Topological Data Analysis \cite{Carlsson2009,Ghrist2008}, seeks to quantify shape and structure in data sets.
Algebraic topology \cite{Hatcher,Munkres2000} is a field of mathematics which quantifies qualitative similarities in the structure of spaces.
One such method for quantification is homology, which, given a topological space, provides a vector space\footnote{We work with field coefficients, most typically $\mathbb Z_2$, so the homology group is, in fact, a vector space.} for each dimensional structure being studied.
This paper will only focus on dimension 0, which quantifies connected components.

The intuition behind persistent homology for a point cloud data set is to increase a connectivity parameter, and quantify how the topological structure changes.
This powerful method can find interesting, higher dimensional structure, using each dimension of homology, however, we will look at the simplest version for the purposes of our problem.
Zero-dimensional persistent homology  quantifies how the clusters change when viewed at different scales.
In fact, 0-dimensional persistent homology is closely related to classical clustering methods such as single-linkage hierarchical clustering, dendrograms, and minimal spanning trees \cite{Murtagh2011}.
Here, we adopt the view of the procedure as a restricted case of persistent homology in order to gain understanding and predictive power in our analysis, thus resulting in Thm.~\ref{thm:MainResult}.

In the general setting, assume we are given a point cloud $\chi \subset \mathbb R^D$ with $|\chi| = n$.
We can define a function $f_\chi:\mathbb R^D \to \mathbb R$ by
$f_\chi(x) = 2\|x - \chi\|$ where $\|x-A\| = \inf_{y \in A} \|x-a\|$ for any set $A \subset \mathbb R^D$.
The set of points for which $f_\chi(x) \leq r$ is the union of $D$-dimensional balls of radius $\frac{1}{2}r$ centered at the points of $\chi$;
we write this as $f_\chi^{-1}(-\infty,r]$.
If we allow $r$ to increase from $0$, initially, $f_\chi^{-1}(-\infty,r]$ has $n$ distinct connected components.
However, as $r$ is increased, these components will merge together until we are finally left with only one connected component.
In particular, these mergings happen at the instant two disks touch, and thus when $r$ is equal to the distance between the associated points.
We say that a connected component dies when it merges with another connected component; that is, a death occurs any time two clusters merge.
We can keep track of the function values at which these deaths occur in the following manner.

A function value $r$ is a homological critical value if the number of connected components decreases at function value $r$.
The multiplicity of a critical value is the net decrease in the number of connected components.
We define $\mathrm{dgm}(\chi) \subset \mathbb R$ to be the collection of homological critical values, with number of copies equal to the multiplicity.
The resulting set of values is called a 0-dimensional persistence diagram, notated $\mathrm{dgm} = \{d_1 \leq d_2 \leq \cdots \leq d_k\}$.%
\footnote{Experts will notice that, in general, persistence diagrams are given as collections of points in $\mathbb R^2$.  Since for 0-dimensional persistence on point clouds, all components are born at 0, the true persistence diagram would be the collection $\{(0,d_1),\cdots,(0,d_k)\}$.  We elect to drop the repeated first coordinate in order to simplify the description.}
One observation that will be useful for interpretation is that the number of connected components of $f^{-1}(-\infty,r]$ is one more than the number of $d_i \in \mathrm{dgm}$ with $d_i > r$.

We will also use the slightly more general formulation of persistence for any subset $A \subset \mathbb R^D$.
If $f_A: \mathbb R^D \to \mathbb R$ is given by $f_A(x) = 2\|x-A\|$, $\mathrm{dgm}(A)$ is the collection of function values for which the number of connected components of $f^{-1}(-\infty,r]$ changes, again with multiplicity.
In order to ensure that the persistence diagrams are finite, we assume that $A$ has finitely many connected components.

\begin{figure}[tb]
	\centering
	\includegraphics[height = 1.3in,draft = False,valign = t]{PtCloudClusterExample}
	\includegraphics[height = 1.35in,draft = False,valign = t]{PtCloudClusterExample_DgmHist}
	\includegraphics[width = .2\textwidth, draft = False,valign = t]{bottleneckPairing.png}
	\caption{Left, an example point cloud with its 0-dimensional persistence diagram drawn as a histogram at center.  Right, an example of the pairing for two persistence diagrams used to compute the bottleneck distance.}
	\label{fig:point_cloud_cluster_hist}
\end{figure}

\subsection{Stability of Persistence Diagrams}
\label{ssec:stabilityBkgd}

The main reason for thinking of this information as a persistence diagram is that these structures come with a metric known as the bottleneck distance.
Here we describe the metric in the restricted 0-dimensional persistence diagram setting; see e.g.~\cite{Edelsbrunner2010} for the full definition.
Given two 0-dim persistence diagrams, $\mathrm{dgm}_1 = \{d_1 \leq d_2 \leq \cdots \leq d_k\}$ and $\mathrm{dgm}_2 = \{e_1 \leq e_2 \leq \cdots \leq e_\ell\}$, a partial matching $\eta$ is a bijection between subsets of the two diagrams $\eta: A \to B$, $A \subset \mathrm{dgm}_1$, $B \subset \mathrm{dgm}_2$.
The cost of a matching is defined to be
\begin{equation*}
c(\eta) = \max\left(
\bigg\{ |a - \eta(a)| \bigg\}_{a \in A} \cup
\bigg\{ \frac{a}{2} \bigg\}_{a \in \mathrm{dgm}_1 \setminus A} \cup
\bigg\{ \frac{b}{2} \bigg\}_{b \in \mathrm{dgm}_2 \setminus B}
\right)
\end{equation*}
and the bottleneck distance
$d_B(\mathrm{dgm}_1,\mathrm{dgm}_2) = \min_{\eta} c(\eta)$
is the minimum cost of the possible matchings.
Notice that because we are restricting our diagrams to finitely many points, the set of matchings is finite, thus this minimum is always achieved.
In addition, it is possible that multiple matchings achieve the minimum, so we will reference such a matching as \textit{a} min-cost matching.

Consider, for example, a diagram consisting of a single point $\mathrm{dgm}_1 = \{d_1\}$ vs a diagram with two copies of the same point $\mathrm{dgm}_2 = \{e_1,e_2\}$.
WLOG, assume $e_1\geq e_2$.
The only possible matchings are where $\eta_1(d_1) = e_1$, $\eta_2(d_1) = e_2$, or $\eta_3$ which matches nothing.
The scores of these are
$c(\eta_0) = \max\left\{\tfrac{d_1}{2}, \tfrac{e_1}{2}, \tfrac{e_2}{2}\right\}$,
$c(\eta_1) = \max\left\{|d_1-e_1|, \tfrac{e_2}{2}\right\}$,
and
$c(\eta_2) = \max\left\{|d_1-e_2|, \tfrac{e_1}{2}\right\}$.
In the example of the two persistence diagrams in the right of Figure \ref{fig:point_cloud_cluster_hist}, the score is lowest using $\eta_1$, so the distance between the diagrams is $\max\left\{|d_1-e_1|, \tfrac{e_2}{2}\right\}$.

The bottleneck distance is particularly useful due to the stability theorem \cite{Cohen-Steiner2007}.
Recall that the Hausdorff distance between sets $A,B \subset \mathbb R^D$ is
\begin{equation*}
d_H(A,B) = \max \left\{ \sup_{a \in A} \|a-B\|, \sup_{b \in B} \|b-B\| \right\}.
\end{equation*}
Then the stability theorem is as follows.
\begin{thm}
[\cite{Cohen-Steiner2007}]
\label{thm:stability}
Under mild assumptions on the sets $A,B \subset \mathbb R^D$\footnote{The distance functions $f_A$ and $f_B$ must be what is known as \textit{tame} in the TDA literature.
As all sets considered in this paper have finitely many connected components in $\mathbb R$, we will always satisfy this assumption. },
\begin{equation*}
d_B(\mathrm{dgm}(A), \mathrm{dgm}(B)) \leq d_H(A,B).
\end{equation*}
\end{thm}
This theorem is particularly useful when we take the view, as we will need in Section \ref{sec:method}, that $B$ is a noisy point cloud approximation of $A$.
In this case, $d_H(A,B)$ is small, so the resulting persistence diagrams will be close as well.

Let us now explore what it means for a diagram to be close to another diagram.
Assume we again have a diagram with a single point $\mathrm{dgm}_1 = \{d_1\}$.
For $\varepsilon$ small relative to $d_1$, we can think of the set of diagrams within distance $\varepsilon$ of $\mathrm{dgm}_1 = \{d_1\}$.
Say the second diagram is $\mathrm{dgm}_2 = \{e_1,\cdots,e_n\}$, so the options for matchings are $\eta_i$ matching $d_1$ to $e_i$ for $i=1,\cdots,n$, and $\eta_0$  matching nothing.
Assume $d_B(\mathrm{dgm}_1,\mathrm{dgm}_2) \leq \varepsilon$ and let $\varepsilon < d_1/3$.
If a minimum cost matching is $\eta_i$, this implies $|d_1 - e_i| \leq \varepsilon$, and $e_j \leq 2\varepsilon$ for all $j \neq i$.
This means that there must be exactly one point, $e_j$, within distance $\varepsilon$ of $d_1$, and all remaining points are in $[0,2\varepsilon]$.
As shown in the rightmost portion of Figure \ref{fig:point_cloud_cluster_hist}, this means there is exactly one point in the top green region, and any remaining points are in the bottom green region.

What will be useful in Section \ref{sec:method}\ref{ssec:diamOfPulses} is the set of diagrams close to the diagram which has $n$ copies of the point $d_1$, e.g.~$\mathrm{dgm}_n = \{d_1,d_1,\cdots,d_1 \}$, .
In this case, any diagram within bottleneck distance $\varepsilon$ (again sufficiently small $\varepsilon < d_1/3$), will have exactly $n$ points in $[d_1-\varepsilon,d_1+\varepsilon]$, with all remaining points less than $2\varepsilon$.

\subsection{Computation of the persistence diagram using MSTs}
\label{sec:MST}
In order to do computations, we convert this information into combinatorial structures.
Following \cite{Robins1998,Robins2000a}, we compute persistence using a minimal spanning tree.
A \textit{graph} $G = (V(G),E(G))$ consists of a finite list of vertices $V(G)$ and a set of edges, $E(G)$, between them.
A graph is \textit{complete} if every pair of vertices has an edge between them.
A \textit{subgraph} $A \subseteq G$ is a subset of $G$ which is itself a graph.
That is, $A = (V(A),E(A))$ where $V(A) \subseteq V(G)$, $E(A) \subseteq E(G)$.

A \textit{path} in $G$ is a sequence of vertices $v_0,\cdots,v_n$ such that there is an edge between every adjacent pair: $(v_i,v_{i+1}) \in E(G)$ $\forall i$.
A path is a \textit{cycle} if $v_0 = v_n$.
A graph is \textit{connected} if there is a path between every pair of vertices.
A graph is a \textit{tree} if it is connected and there are no cycles.
A subgraph $T \subseteq G$ which is a tree and with $V(T) = V(G)$ is called a \textit{spanning tree}.

A weighted graph $G = (V(G),E(G),\omega)$ is a graph with a real value, called a weight, associated to each edge: $\omega: E(G) \to \mathbb R$.
The \textit{total weight} of a spanning tree of a weighted graph is the sum of the weights on the edges.
A spanning tree is called a \textit{minimal spanning tree (MST)} if it has minimal total weight amongst the set of spanning trees.
If $G$ is not connected, no MST exists as there is no connected subgraph using all the vertices.
A \textit{minimal spanning forest (MSF)} is an acyclic subgraph such that the restriction to each connected component of $G$ is a MST.

Given a finite set of points $\chi \subset \mathbb R^D$, the \v{C}ech  graph for parameter $r>0$ is the complete graph $\textrm{\v{C}}(\chi,r)$ with vertex set in 1-1 correspondence to the points in $\chi$, with all edges $(x,y)$ for which $\|x-y\| \leq r$, and with edge weight equal to the distance between the associated points.
First, notice that if $r\leq s$, $\textrm{\v{C}}(\chi,r) \subseteq \textrm{\v{C}}(\chi,s)$.
Second, if $r$ is larger than the diameter of $\chi$ (which is finite since $\chi$ is finite), $\textrm{\v{C}}(\chi,r)$ is a complete graph and $\textrm{\v{C}}(\chi,r) = \textrm{\v{C}}(\chi,s)$ for all $s \geq r$.
Thus, we denote this graph as $\textrm{\v{C}}(\chi,\infty)$.

Our first intuition of understanding the connected components of the union of disks as described above is to watch the connected components of $\textrm{\v{C}}(\chi,r)$ change as $r$ increases.
It is a consequence of the celebrated Nerve Lemma \cite{Hatcher} that the connected components of $\textrm{\v{C}}(\chi,r)$ match up with the connected components of the union of disks of radius $\tfrac{r}{2}$; equivalently with the connected components of $f_\chi(-\infty,r]$ in the notation of the previous section.
So, we just need to determine the list of function values for which the connected components of $\textrm{\v{C}}(\chi,r)$ change.

Let $T$ be a MST for $\textrm{\v{C}}(\chi,\infty)$\footnote{This is sometimes called a ``Euclidean spanning tree''.}.
It is an immediate consequence of the results \cite{Robins2000a} that the list of weights on the edges of $T$ is exactly $\mathrm{dgm}(\chi)$.
Restated in our notation, this is the following.
\begin{lemma}[{\cite[Lem.~3]{Robins2000a}}]
Let $T$ be a MST for $\textrm{\v{C}}(\chi,\infty)$,
and let $T_r$ be the restriction to the set of edges of weight at most $r$ so that $T_r \subset \textrm{\v{C}}(\chi,r]$.
Then $T_r$ is a MSF for $\textrm{\v{C}}(\chi,r]$.
\end{lemma}
Since a MSF of a graph has the same connected components as the graph itself, this means that the changes in the connected components happen exactly at the values of the weights in $T$.
Putting this all together, we have the following theorem.
\begin{thm}
For a finite set of points $\chi$, $\mathrm{dgm}(\chi)$ is the set of weights on the edges of a MST of $\textrm{\v{C}}(\chi,\infty)$.
\end{thm}

The final thing to note is that we will largely be interested in points in $\mathbb R$ (so $D=1$).
Say $\chi = \{a_0,\cdots,a_k\}$.
In this case, it is obvious that the MST is exactly the graph with edges $\{(a_i,a_{i+1})\}_{i=0}^{k-1}$, and so the diagram $\mathrm{dgm}(\chi) = \{(a_{i+1}-a_i)\}_{i=0}^{k-1}$.

\section{Method}
\label{sec:method}

\subsection{Basic model assumptions}
\label{ssec:modelAssumptions}
The initial data is a time series $X$ defined on $\{a=t_0 <t_1<\cdots<t_N=b\}$
given by $\{X(t_0), X(t_1),\cdots,X(t_N)\}$.
We assume that this data approximates the pulse wave $P_T^\tau$ given by
\begin{equation*}
P_T^{\tau}(t) =
\begin{cases}
1 & \text{if } 0 \leq (t \mod T) \leq \tau\\
0 & \text{else}
\end{cases}
\end{equation*}
and shown in Figure \ref{fig:PulseTrain}.
We will assume that the duty, $\delta = \tau/T$, is less than $0.5$ since otherwise we could swap our analysis to check for the pulses at 0 instead of the pulses at 1.

We first assume that our noisy data is given by
\begin{equation}
\label{eq:ModelSimple}
X(t) = P_T^\tau(t+\delta_x) + \delta_y
\end{equation}
where
$\delta_x \sim \mathrm{unif}(-\alpha\cdot \tau,\alpha\cdot \tau)$ and
$\delta_y \sim \mathrm{unif}(-\beta,\beta)$ with $\alpha \in [0,1/2]$ and $\beta \in [0,1]$.
For simplicity, we assume the noise in $y$, $\delta_y$, separates the high and low values, so
$\beta \ll \tfrac{1}{2}$.
The noise in $x$, $\delta_x$, serves to give incorrect pulse values when we near the beginning or end of a pulse by looking forward and backward in time to reach an output.
Since $\alpha$ is given as percentage of $\tau$, and we will not be able to see anything if $\alpha$ is large enough to entirely erode the off-cycle with digital ringing, we assume
$\alpha \leq \tfrac{T-\tau}{3\tau}$.
For practical applications with a small $\tau$, this is satisfied for any $\alpha \in [0,1/2]$.

It will be important later to note that with these assumptions on $\beta$ and $\alpha$, the Hausdorff distance between $M$ and $\chi = \{t \mid X(t) \geq \tfrac{1}{2}\}$ for any realization of $\{X(t)\}$  dense enough in $t$ will be bounded by $\alpha \tau$.

\begin{figure}[tb]
\centering
\includegraphics[width = .23\textwidth,valign = t, draft = False]{PulseTrainShort.jpg}
\includegraphics[width = .36\textwidth,valign = t,, draft = False]{NoisyPulseTrain.jpg}
\includegraphics[width = .36\textwidth,valign = t,, draft = False]{NoisyPulseTrainAccordion.jpg}
\caption{Left, an ideal pulse train $P_T^\tau$.
Center and right, noisy instances of the pulse train, both with
$T = 2$,
$\tau = .5$,
$\alpha = .05$, and $\beta = .05$.
The center figure has $\varepsilon = 0$ and the right figure has $\varepsilon = .5$. Note the uneven, random pulse spacing for $\epsilon \neq 0$.}
\label{fig:PulseTrain}
\end{figure}

\subsection{Counting pulses and RPM calculation using persistence}
\label{ssec:diamOfPulses}

\begin{figure}[tb]
\centering
\includegraphics[width = .5\textwidth, draft = False]{ExampleSubsetsPulseTrain}
\includegraphics[width = .3\textwidth, draft = False]{DistanceHistogram}
\caption{
A pulse train, with $T = 2$, $\tau = .8$, $\alpha = .2$, $\beta = .1$, is shown at left.
The corresponding sets $\chi$ and $M$ are drawn above. The choices of domain for the RPM computation is shown by the green lines.
The histogram for the points in the 0-dimensional diagram for the example of Figure \ref{fig:PulseTrain2}.  Note that there is a large split between the non-empty bins, so we can choose any threshold $\mu \in [0.2,1.0]$.}
\label{fig:PulseTrain2}
\end{figure}

Counting the number of pulses in a range $[A,B]$ can be thought of as counting the number of connected components of $M = (P_T^\tau)^{-1}(\{1\}) \cap [A,B]$.
With this in mind, we use a special case of 0-dimensional persistence to determine this from the point cloud approximation of $M$, namely
$\chi = \{t_i \mid X(t_i) >\tfrac{1}{2}\}$.
See Figure \ref{fig:PulseTrain2} for an example.

In order to determine the persistence-based RPM $\Omega_P$, we need to find the range on the $t$-axis containing the full periods, and count the number of full periods there.
In some sense, this procedure is measuring the voids between the components of $M$, rather than measuring the components of $M$ themselves.
The following theorem essentially outlines an algorithm, which, given controlled enough noise, dense enough sampling, and enough visible pulses, calculates the number of pulses in that region using the persistence diagram $\mathrm{dgm}(\chi)$.

\begin{thm}
\label{thm:MainResult}
Assume a time series $X(0),X(t_1),\cdots,X(t_N)$ is data drawn from the model of Eq.~\ref{eq:ModelSimple} with $\alpha < \frac{1}{5}(\frac{T}{\tau}-1)$, and $\beta < .5$, and with times $\{A=t_0<t_1<\cdots<t_N = B\}$ evenly spaced such that $t_i-t_{i-1} < \tau(1-2\alpha)/2$ and $(B-A)/T > 3$.
Set $\chi = \{t_i \mid X(t_i) >\tfrac{1}{2}\} = \{a_1\leq\cdots\leq a_m\}$ and denote the resulting persistence diagram $\mathrm{dgm}(\chi) = \{b_1\leq\cdots\leq b_\ell\}$.
Choose $\mu   \in (d_j, d_{j+1})$ for
$j = \mathrm{argmax}_k\{d_{k+1}-d_k\}$.
Then
$|\{d \in \mathrm{dgm}(\chi) \mid d > \mu\}| - 1$
is the number of pulses in the range
\begin{equation}
\label{eq:DefnALowHigh}
A  < A_{\mathrm{low}} :=
\left( \left\lceil \frac{A-\tau}{T} \right\rceil +1\right)T
<
\left\lfloor \frac{B}{T} \right\rfloor T =: A_{\mathrm{high}}
\leq B.
\end{equation}

\end{thm}

In particular, since $A_{\mathrm{low}}$ and $A_{\mathrm{high}}$ can be approximated within $\alpha \tau$ by
\begin{align*}
a_{\mathrm{low}} &= \min\{a_i \in \chi \mid a_i-a_{i-1} > \mu\}, \textrm{ and}\\
a_{\mathrm{high}} &= \max\{a_i \in \chi \mid a_i-a_{i-1} > \mu\},
\end{align*}
this theorem allows us to approximate the RPM in the following sections as
\begin{equation}
\label{eqn:RPM}
\mathrm{\Omega_P} =
\frac{\#\{d \in \mathrm{dgm}(\chi) \mid d \geq \mu\} - 1 }{a_{\mathrm{high}} - a_{\mathrm{low}}}.
\end{equation}.

\begin{proof}

First, note that if $M$ has $m$-connected components, there will be $m-1$ mergings of components that occur exactly at distance $T-\tau$.
Thus, the persistence diagram of $M$, $\mathrm{dgm}(M)$, has $m-1$ copies of $d_1 = T-\tau$.
By definition of the noise parameters $\alpha$ and $\beta$, we know that the Hausdorff distance between $M$ and $\chi$ is at most $\alpha \tau$.
So, by the stability theorem, Thm.~\ref{thm:stability}, we have that
$d_B(\mathrm{dgm}(M),\mathrm{dgm}(\chi))<\alpha\tau$.

Thus, we turn our attention to computation of the 0-dimensional persistence of $\chi$.
As discussed previously, the MST for points in $\mathbb R$ has edges $\{(a_i,a_{i-1})\}_{i=0}^{k-1}$.
Hence, the set of pairwise distances  $\{a_1-a_0, a_2-a_1,\cdots, a_n-a_{n-1}\}$ is exactly the 0-dimensional persistence diagram $\mathrm{dgm}(\chi)$.

The set of possible 0-dimensional diagrams within bottleneck distance
$\alpha\tau$ of $\mathrm{dgm}(M)$ have exactly $m-1$ points in
$[(T-\tau )-\alpha\tau, (T-\tau) + \alpha\tau]$,
and all remaining points are in $[0,2\alpha\tau]$.
Requiring $\alpha < \frac{1}{5}(\frac{T}{\tau}-1)$ means that there will be a distinct split in $\mathrm{dgm}(\chi)$; in particular that the largest difference between points in the diagram will occur between a point in $[0,2\alpha\tau]$ and a point in $[(T-\tau )-\alpha\tau, (T-\tau) + \alpha\tau]$.
These points are then notated as $d_j$ and $d_{j+1}$ where
$j = \mathrm{argmax}_k\{d_{k+1}-d_k\}$.

We choose a threshold $\mu$ between the collections, and count $\#\{d \in \mathrm{dgm}(\chi) \mid d \geq \mu\} + 1$; that is to say, the number of points in the diagram in the interval $[(T-\tau )-\alpha\tau, (T-\tau) + \alpha\tau]$, so this is $m-1$.

While it is an annoying case study in number theory to determine exactly how many pulses appear in the interval $[A,B]$, what we can say is that if we cut off the first (possibly partial) pulse seen, and the last (possibly partial) pulse seen by looking in the interval $[A_{\mathrm{low}}, A_{\mathrm{high}}]$ defined in Eq.~\ref{eq:DefnALowHigh}
then the number of pulses is $m -2$.
Thus, the theorem follows.
\end{proof}

\subsection{Counting pulses and RPM calculation using Fourier transform}
\label{sec:fourier_rpm}
The pulse counting and RPM calculation can be obtained by transforming the signal to the frequency domain. Specifically, the one-sided Fourier transform of the signal is obtained after subtracting the mean value from it to remove the DC component from the spectrum. Then, the frequency $f$ in Hertz corresponding to the first amplitude $A$ that satisfies $A > A_{\text{max}}/w$ is found, where $w$ is a scalar, and the Fourier-based RPM $\Omega_{\text{F}}$ is calculated according to
\begin{equation}
\label{eq:RPMxFourier}
\Omega_{\text{F}} = f_1 \times 60.
\end{equation}
In this study we chose $w=3$ since it provided accurate results for the studied cases with constant peak spacing. However, other values of $w$ did not improve the accuracy of the method for the cases with non-constant peak spacing, and therefore the deterioration in the performance of the Fourier-based approach  for these case was not related to our choice of $w=3$.

\subsection{Accordion model assumptions}
\label{ssec:accordion}
We now create a generalized model for testing purposes where we have data which does not maintain regular pulses.
This model will generate data on a window $[0,W]$.
Assume $Q_1,\cdots,Q_K$ are drawn iid from $\mathrm{unif}((1-\varepsilon)T,(1+\varepsilon)T)$.
We assume $\varepsilon \in [0,1]$ and $K>\frac{W}{(1-\varepsilon)T}$ is large enough to ensure that $\sum_{i=1}^K Q_i \geq W$.
We will generate pulses so that the length of the $i$th period is $Q_i$.

For the sake of notation, let $Q_0 = 0$.
For any $s \in [0,W]$, define
$\sigma(s) = \max\{j \in [0,\cdots,K] \mid \sum_{i=0}^jQ_i \leq s\}$.
The reparameterization function is given by
\begin{equation*}
\phi(s) =
\left(
	T\cdot \sigma(s)
\right)
	 +
\frac{T}{Q_{\sigma(s)+1}}
\left(s - \sum_{i=0}^{\sigma(s)}Q_i\right).
\end{equation*}
Then the noisy time series is given as
\begin{equation}
\label{eq:ModelAccordion}
X(s) = P_T^\tau(\phi(s)+\delta_x) + \delta_y
\end{equation}
where $\delta_x$ and $\delta_y$ are noise as defined in Sec.~\ref{ssec:modelAssumptions}.
See Fig.~\ref{fig:PulseTrain} for an example.
Notice that this model simplifies to Eq.~\ref{eq:ModelSimple} when $\varepsilon = 0$.

\section{Numerical Simulations and Robustness Analysis}
\label{sec:robust_analysis}
This section describes the numerical simulations and shows the results of the robustness analysis.
The basic idea is to take a standard pulse train with a small duty cycle and introduce spurious peaks at both the rising and the falling edge of the data using a uniformly distributed random variable as defined in Eq.~\ref{eq:ModelSimple}.
This noise is found to mimic the digital ringing noticed in the laser tachometer experimental data discussed in Sec.~\ref{sec:experimental_apparatus}.
Further, we simulate data from a signal where the spacing between the peaks is non-constant as defined in Eq.~\ref{eq:ModelAccordion}.
The signal with modulated peak separation simulates, for example, a heavy cutting process where the spindle speed varies during the cut.
Alternatively, this spindle speed variation might be intentionally introduced to mitigate chatter and improve the cutting process \cite{Sexton1978, Yilmaz2002, Lin1990, Radulescu1997}.
The basic parameters used in the simulation are shown in Table \ref{tab:simParams}.

\begin{table}[tbp]
\centering
\begin{tabular}{c|c|c}
Parameter & Description  & Value(s) studied \\
\hline
$\delta $& nominal duty cycle for the pulse & $5\%$ \\
$\Omega_0$ & nominal RPM & $[30, 24000]$ \\
$T$ & nominal period of the pulse in seconds & $60/\Omega_0$ \\
$\tau$ & time in on cycle &  $\delta \cdot T$\\
$\alpha$ & uniform noise in $x$ as \% of $\tau$  & $[0, 0.5]$\\
$\beta$ & uniform noise in $y$ as \% of amplitude  & 0\\
$\epsilon$ & peaks' spacing uniform noise amplitude/$T $& $[0.02, 0.65]$ \\
$n$ & number of periods to simulate & $32$ \\
$m$ & oversampling factor & $32$ \\
$N$  & number of simulation points & $N=m ( \Omega_0/60)  nT$
\end{tabular}
\caption{The parameters used in the numerical simulations.}
\label{tab:simParams}
\end{table}
In order to test the robustness of the persistence-based algorithm, the described numerical simulations were utilized in a number of analyses which include:
\begin{enumerate}[nosep, labelindent=0pt]
	\item Investigating the described approach as a function of digital ringing. This is controlled by the parameter $\alpha$ which specifies, as a percent of $\tau$, the interval around the rising and falling edges that will be affected by digital ringing. The digital ringing is introduced using a uniformly distributed variable defined on the interval described by $\alpha$. Therefore{}, as $\alpha$ gets larger, the digital ringing gets more severe.
	\item Studying the performance of the method when varying the spacing between the peaks (the accordion effect). This is controlled by the parameter $\epsilon$ which represents, as a percent of $T$, the width of the interval that will be modulated by uniform noise. The larger $\epsilon$, the more likely it is for the peaks to get closer.
	\item Analyze the results of our approach versus the well-established Fourier transform method. With Fourier the frequency is found and the RPM or the count of pulses per unit time are then deduced from the prominent frequency components.
	\item Benchmark the computational time of the persistence-based approach versus the heavily optimized Fourier transform approach.
\end{enumerate}
All the simulations and the related analysis were performed using Python's \texttt{scipy} stack.
The numerical simulations consisted of a $100 \times 100$ uniform grid each in the ($\Omega_0$, $\alpha$) plane, and the ($\Omega_0$, $\epsilon$) plane. The simulation grids were defined using $\Omega_0$ $\in [30, 24000]$, $\alpha \in [0, 0.5]$, and $\epsilon \in [0.02, 0.65]$. For both sets of simulations, $100$ replicates were generated at each grid point. The starting seed for the random number generator used to produce the random noise was $48824$, and it was incremented by one for each subsequent iteration. For each grid point, the RPM was calculated using both persistence (Eq.~\ref{eqn:RPM}) and Fourier (Eq.~\ref{eq:RPMxFourier}). The computation time for each method was also recorded using the performance counter from Python's \texttt{time} package.

The sample mean was used as the point estimator on each grid point.
The relative error between the output of each algorithm (Fourier, and persistence) and the nominal RPM $\Omega_0$ was computed.
The results that show a comparison between Fourier and persistence are summarized in Fig.~\ref{fig:fullheatmap}.
The left and right columns correspond to persistence-based and Fourier-based results, respectively.
The first row is for varying the accordion parameter $\epsilon$, while the second row corresponds to varying the digital ringing parameter $\alpha$. The same color scale is used for both heat maps in the same row, and higher values on the color scale indicate larger relative error.

\begin{figure}[htbp]
\centering
\includegraphics[width=\textwidth, draft = False]{full_heat_map_comparison.png}
\caption{Heat maps showing a comparison of the relative errors between the calculated RPM using persistence (left column) and Fourier (right column). The first row shows the comparison in the ($\Omega_0$, $\epsilon$) plane, while the second row compares the two algorithms in the ($\Omega_0$, $\alpha$) plane. Note that the color scale is fixed for each row to facilitate the comparisons. }
\label{fig:fullheatmap}
\end{figure}

\subsection{\texorpdfstring{$\alpha$}{alpha} versus \texorpdfstring{$\Omega_0$}{nominal RPM}}
The left heat map in the bottom row of Fig.~\ref{fig:fullheatmap} shows that persistence performed significantly better than Fourier. Specifically, the relative error of the persistence algorithm is below $7\%$ for $\alpha < 30\%$. In contrast, the error in Fourier is as high as $24\%$ for $\alpha < 30\%$ and goes to at least $40\%$ for $\alpha > 35\%$.
Note that in both rows of Fig.~\ref{fig:PulseTrain} the color scale is the same. A closer look at the heat map of persistence in Fig.~\ref{fig:alphaVsRpm} shows how the error in the persistence algorithm is between $15\%$ and $25\%$ but only for $\alpha > 30\%$.
These are large values that correspond to a signal with very strong variations between the peaks.
Note that even though we show the results for $\alpha \in [0, 0.5]$, we could deal with the case of $\alpha > 0.5$ by reversing the persistence algorithm from looking at the gaps between peaks (logic zero) to looking at logic one (high values in the two-level digital signal).
Therefore, the user has the flexibility of adjusting the algorithm to recover good performance, as needed.

\begin{figure}[t!]
\centering
\includegraphics[width=\textwidth, draft = False]{pers_vary_alpha.png}
\caption{Top left: A figure showing more details of the heat map that depicts the relative error in the persistence-based RPM as a function of $\Omega_0$ and $\alpha$. Top right, bottom left, and bottom right: The calculated RPM using persistence and Fourier algorithms for $\alpha=10\%$ and the RPM values $3178$, $12136$, and $20126$, respectively. The nominal RPM values are marked using horizontal black lines. The bands around the line represent the $68\%$ confidence bands which were computed using an empirical bootstrap distribution of the sample mean. }
\label{fig:alphaVsRpm}
\end{figure}

Figure~\ref{fig:epsVsRpm} shows the plot of the average RPM versus $\alpha$ calculated using both persistence and Fourier for $\epsilon=25\%$ at three nominal rpms: $3178$ (top right), $12136$ (bottom left), and $20126$ (bottom right).
The nominal RPM is indicated on the figure using a solid, horizontal black line.
The curves for the calculated persistence and Fourier RPM values also include the $68\%$ confidence band that can be seen in the inset panels of the top right figure.
These confidence bands were computed using an empirical bootstrap distribution of the sample mean.
It can be seen that for $\alpha < 20\%$, Fourier consistently underestimates all three nominal RPM values.
Moreover, as $\alpha$ is increased beyond $20\%$, the Fourier estimate starts to decrease further below the nominal RPM.
In contrast, persistence gives close estimates of the nominal RPM for $\alpha < 25\%$, and only tends to consistently undershoot the nominal RPM for $\alpha >25\%$.
Therefore, the bottom rows in Figs.~\ref{fig:fullheatmap} and \ref{fig:alphaVsRpm} show that the persistence algorithm is robust to the width of the digital ringing.

\subsection{\texorpdfstring{$\epsilon$}{epsilon} versus \texorpdfstring{$\Omega_0$}{nominal RPM}}

The top row of Fig.~\ref{fig:fullheatmap} shows that for $\epsilon < 7\%$ the two algorithms produce comparable results with less than $10\%$ relative error. However, as $\epsilon$ is increased, the performance of Fourier progressively deteriorates from $10\%$ to greater than $40\%$ as evidenced by the increase in the relative error across approximately four horizontal bands with a width of $10\%$ each. These bands are roughly given by
$\epsilon \leq 15\%$,
 $18\% < \epsilon \leq 30\%$,
 $30\% < \epsilon \leq 40\%$,
and $\epsilon > 40\%$.
In contrast, the left heat map in the first row shows that persistence consistently maintains less than $10\%$ error for almost all values of $\epsilon$; however, errors start to increase for $\epsilon > 42\%$. The deterioration of the performance of the described approach is better observed from the heat map in Fig.~\ref{fig:epsVsRpm} where higher relative errors start occurring towards the upper limit of the $\epsilon$ values.

In addition to the heat map that shows the relative error as a function of $\epsilon$ and $\Omega_0$, Fig.~\ref{fig:epsVsRpm} shows the plot of the average RPM versus $\epsilon$ calculated using both persistence and Fourier for $\alpha=10\%$ at three nominal RPM values: $3178$ (top right), $12136$ (bottom left), and $20126$ (bottom right).
The nominal RPM is indicated on the figure using a solid, horizontal black line.
The curves for the calculated persistence and Fourier rpms also includes the $68\%$ confidence band that can be seen in the inset panels of the top right figure.
These confidence bands were computed using an empirical bootstrap distribution of the sample mean.
We can see that for both algorithms the confidence bands are narrow.
Further, it can be seen that for $\epsilon < 5\%$ both algorithms are close to the nominal value for all three RPM choices.
However, for $\epsilon > 5\%$, the Fourier algorithm quickly diverges away from the nominal RPM while persistence remains close to the nominal value.
As $\epsilon$ is increased to $45\%$, we start to see persistence undershooting the nominal value which indicates that at high values of $\epsilon$, persistence undercounts the true peaks.
Therefore, the top rows in Figs.~\ref{fig:fullheatmap} and \ref{fig:epsVsRpm} show that the persistence algorithm is robust to the variation in the spacing between the peaks.

\begin{figure}[tb]
\centering
\includegraphics[width=\textwidth, draft = False]{pers_vary_eps.png}
\caption{Top left: A figure showing more details of the heat map that depicts the relative error in the persistence-based RPM as a function of the nominal RPM and $\epsilon$. Top right, bottom left, and bottom right: The calculated RPM using persistence and Fourier algorithms for $\epsilon=25\%$ and the RPM values $3178$, $12136$, and $20126$, respectively. The nominal RPM values are marked using horizontal black lines. The bands around the line represent the $68\%$ confidence bands which were computed using an empirical bootstrap distribution of the sample mean. }
\label{fig:epsVsRpm}
\end{figure}

\subsection{Runtime comparison} \label{sec:runtime}
\begin{figure}[t!bp]
\centering
\includegraphics[width=0.75\textwidth, draft = False]{run_time}
\caption{Average runtime for all trials as a function of the nominal RPM, i.e., the signal length.}
\label{fig:runtime}
\end{figure}
In terms of theoretical runtime, the algorithm for computing $\Omega_P$ is simple, requiring only a sequence of pairwise subtractions and sortings.
Since these take $O(n)$ and $O(n\log n)$ respectively, the theoretical worst case runtime for the persistence based algorithm is $O(n\log n)$.
Meanwhile, the FFT algorithm computes the Fourier transform in $O(n\log n)$ as well, so the worst case analysis of the two methods is the same.

Runtime benchmarks for Fourier and persistence algorithms were measured using the performance counter from Python's \texttt{time} package.
The machine used for the simulations is a standard desktop running Ubuntu 16.04 with 32GB ram and a 3.6GHz Intel i7 processor.
A total of $200$ runs for each algorithm was performed at each value of the nominal RPM.
The nominal RPM is kept as a variable of runtime because it controls the length of the simulated pulse (see Table \ref{tab:simParams}), and consequently, the runtime for each algorithm. The different runs were then averaged for each algorithm, and the results are plotted in Fig.~\ref{fig:runtime}.
The line in the figure describes the average while the bands represent the $68\%$ confidence interval obtained by bootstrap sampling of the replicates. Notice the small $y$-axis scale in Fig.~\ref{fig:runtime} indicating that both algorithms run relatively fast. However, the figure shows that persistence runs slightly faster than Fourier, and that the runtime is approximately constant across the RPM range.
In contrast, the runtime for Fourier varies more than its persistence counterpart for the different values of the nominal RPM.

\section{Experimental verification}
\label{sec:experimental_apparatus}
\begin{figure}[tbp]
	\centering
	\includegraphics[width=0.45\textwidth]{lasertach_back}
	\hfill
	\includegraphics[width=0.45\textwidth]{lasertach_side}
	\caption{The experimental apparatus consists of a laser tachometer mounted against a rotating spindle. The left picture shows the back view while the right picture shows the side view. Half of the spindle is fitted with white tape whereas the other half is covered with black tape.}
	\label{fig:lasertachExp}
\end{figure}
The experimental apparatus is shown in Fig.~\ref{fig:lasertachExp}. It consists of a Terhahertz Technologies LT-880 Laser Tachometer mounted against the spindle of a Clausing-Gamet 33 Centimeters (13 inch) engine lathe. The laser beam is emitted onto a point along the circumference of the spindle. Half of the spindle is covered with white tape, while the other half is covered with black tape. When the emitted light beam is reflected back to the tachometer's receiving lens, a 5 volt TTL pulse is registered. These pulses are captured by an NI USB-6366 data acquisition box using Matlab. The data is collected using an analog channel to emulate a common practice in industry where sensory inputs in machining processes (including those of laser tachometers) are all collected using analog channels of the same data acquisition device. The signal to noise ratio for laser tachometers is large and it is easy to recover a digital signal by hard-thresholding. In this study, additive normal noise was removed by setting the threshold at 2.5 volts. Thus, any signal above the threshold was set to 1, while signals below the threshold were set to zero.

The experiment was performed using several nominal spindle speeds, which are shown in Table \ref{tab:nominalrpm}. Three trials were performed for each speed and data collection started after the initial spindle ramp up ended. The data was sampled at 80 kHz and the duration of the data collection was chosen such that for each trial the recorded time series captured $30$--$32$ true peaks in the tachometer's pulse train; again, see Table \ref{tab:nominalrpm}.

\begin{figure}[htbp]
	\centering
	\includegraphics[width=0.85\textwidth, draft = False]{experimental_rpm_comparison.jpg}
	\caption{Comparison of $\Omega_P$, $\Omega_F$, and the nominal spindle speeds using experimental data. The inset panels shows that both $\Omega_P$ and $\Omega_F$ are close to each other and to the nominal speed even at the sections where they deviate the most. The figure shows that both $\Omega_P$ and $\Omega_F$ give a speed that is lower than its nominal value for $\Omega_0 > 800$ RPM. This is attributed to the chuck slip effects at the higher range of speeds. }
	\label{fig:experimental_rpm}
\end{figure}

The reason for choosing a sampling rate of 80 kHz is twofold.
First, it is now becoming standard to use digital signal processing (DSP) for low/high/band-pass filtering instead of in-line analog filters.
A conservative rule of thumb in DSP is to oversample by a factor of 16, digitally filter the signal, and then downsample to the frequency range of interest.
Since many signals in cutting processes are collected to study or prevent chatter, which can occur at frequencies of a few thousand hertz, we wanted to make sure that our results apply to cases where by the time all the signals being collected are downsampled by a factor of 16 we can recover a noise-free signal within the range of 5 kHz; so $16 \times 5 = 80$ kHz.
The second reason is that the frequency roll-off of the laser tachometer we are using is 40 kHz.
Therefore, using 80 kHz ensures that we are utilizing the full dynamic range of the sensor.
This eliminates the possibility of attributing the digital ringing we are observing in the signal to insufficient sampling.
Nevertheless, although we are reporting the results when sampling at 80 kHz, we tried other, lower oversampling ratios, e.g., by a factor of 4, and the observed behavior was the same.

Figure \ref{fig:experimental_rpm} shows the results of calculating $\Omega_{\text{P}}$ and $\Omega_{\text{F}}$ using the collected signals. It can be seen that Fourier and persistence results are almost indistinguishable. Further, close examination of the the two inset panels in Fig.~\ref{fig:experimental_rpm}  show that the two curves can cross at several points and trade places. Nevertheless, they remain close and parallel for all practical reasons. A grid is superimposed on the figure to show the expected points on a curve that represents perfect RPM calculation versus $\Omega_0$, the nominal RPM set on the machine. It can be seen from the figure that both $\Omega_{\text{P}}$ and $\Omega_{\text{F}}$ match $\Omega_0$ for $\Omega_0 < 800$ RPM. However, for $\Omega_0 \geq 800$, both $\Omega_{\text{P}}$ and $\Omega_{\text{F}}$ undershoot $\Omega_0$. This was expected since the machine for these spindle speeds was operating at its high range and therefore, spindle slipping and inaccuracies in the $\Omega_0$ were expected. The registered $\Omega_{\text{P}}$ and $\Omega_{\text{F}}$, which are considered more accurate than the nominal value set on the machine, confirm this expectation.

\begin{table}[htbp]
\centering
\begin{tabular}{|ccccccccccccc|}
\hline
\multicolumn{13}{|c|}{Nominal RPM} \\
30 & 40 & 54 & 72 & 98 & 130 & 175 & 235 & 320 & 425 & 570 & 770 & 1030 \\
\hline
62 & 50 & 35 & 30 & 20 & 15  & 12  & 9   & 7   & 5   & 4   & 3   & 3   \\
\multicolumn{13}{|c|}{Duration of data record (seconds)} \\
\hline
\end{tabular}
\caption{The nominal spindle speeds (top block) and the corresponding duration of the data collection for each trial (bottom block). Three records were collected at each nominal RPM. }
\label{tab:nominalrpm}
\end{table}

\section{Conclusions and Discussion}
\label{sec:Conclusions}
This paper described a new approach for step detection using tools from topological data analysis, specifically, 0-dimensional persistent homology.
This viewpoint allows us to provide guarantees via Thm.~\ref{thm:MainResult} for counting pulses even in the presence of digital ringing and stochasticity in period length.
Specifically, the approach involves computing the persistence diagram for the set of times when the time series is above a threshold, and using the widest split in this diagram to determine how many true pulses were seen.
The method is further extended to be able to give an estimation of RPM.

The described approach was verified using numerical and experimental studies.
Specifically, simulated pulse trains with small duty cycles were generated using two independent uniform noise components: one that varied the spacing between the pulses $\epsilon$, and one that introduced spurious peaks near the rising and falling edges of the signal $\alpha$.
The $\alpha$ noise component simulates the digital ringing observed in the experimental data.
The top row of Fig.~\ref{fig:fullheatmap} shows that while both Fourier and persistence methods are resilient to $\epsilon < 7\%$, persistence is better suited for higher $\epsilon$ values.
Specifically, for the Fourier-based approach the relative error progressively grows to about $40\%$ across four horizontal bands of $\epsilon$ intervals while the relative error of the persistence-based approach remains below $10\%$.

The bottom row of Fig.~\ref{fig:fullheatmap} shows that the persistence based approach gives results with a relative error below $7\%$ for $\alpha < 30\%$.
The Fourier-based approach gives errors as high as $24\%$ for the same $\alpha$ range.
Further, the figure shows that while the persistence-based approach gives a relative error between $15\%$ and $25\%$ for $\alpha > 30\%$, the error in the Fourier-based approach is at least $40\%$.
Beyond $42\%$, the described approach can regain its accuracy by detecting high logic between valleys as opposed to detecting low logic between peaks.

A close examination of sample trajectories of $\epsilon$ versus $\Omega_{\text{P}}$ and $\Omega_{\text{F}}$ in Fig.~\ref{fig:epsVsRpm} shows that both methods have tight error bounds.
However, the persistence-based method remains close to $\Omega_0$ while $\Omega_{\text{F}}$ deviates rapidly from $\Omega_0$ for $\epsilon > 5\%$.

Similarly, Fig.~\ref{fig:alphaVsRpm} shows that persistence remains close to $\Omega_0$ with noticeable deviations from $\Omega_0$ starting at $\alpha > 30\%$.
The same figure shows that Fourier-based approach deviates from $\Omega_0$ over the whole $ 0.02 < \alpha < 0.5$ range.

Computationally, persistence and Fourier have the same theoretical runtime as shown in Section \ref{sec:runtime}.
This is confirmed by the benchmark shown in Fig.~\ref{fig:runtime} where it is seen that the average runtime of both algorithms is small although persistence is consistently smaller.
Further, the figure shows larger variations in the runtime of Fourier in comparison to persistence.
The $68\%$ confidence band around the two curves is extremely small, which indicates high confidence in the mean as an estimator of the true runtime.

The experimental investigations depicted in Fig.~\ref{fig:lasertachExp} further established the reliability of the described approach.
Specifically, Fig.~\ref{fig:experimental_rpm} shows that both persistence-based and Fourier-based calculated RPMs are very close.
For the specific lathe used in the experiment, both methods gave spindle speeds close to the nominal value for $\Omega_0 < 800$ RPM.
However, for $\Omega_0 > 800$ RPM, both $\Omega_{\text{P}}$ and $\Omega_{\text{F}}$ yielded RPM values smaller than the nominal.
This discrepancy at higher speeds is attributed to operating the machine at its high range where slipping in the spindle drive can cause the actual RPM to be smaller than the set RPM.

One caveat we mention here is that it is important to pick a span of time that contains a reasonable number of true peaks.
If the picked time span is too long, then the resulting distribution of the gaps (or the peaks if the algorithm is switched around) may fill up the histogram of the points in the persistence diagram (see Fig.~\ref{fig:point_cloud_cluster_hist}) which can make distinguishing the true peaks difficult or impossible.

\subsection{Higher dimensional extensions}
\label{ssec:higherDim}
In essence, we have taken a difficult problem --- clustering points in $\mathbb R^d$ --- to a rather simplified setting --- $d=1$.
This restriction allows for very fast algorithms, particularly owing to the fact that one knows the minimal spanning tree in advance.
Still, algorithms for computing 0-dimensional persistent homology for points in higher dimensions are still quite fast: an implementation using a modified union find algorithm runs in $O(n\alpha(n))$ where $n$ is the number of points and  $\alpha$ is the  notoriously slow growing inverse Ackermann function.

One could, however, imagine higher dimensional signals (i.e., images) where there are sufficient guarantees on the pulse rate and noise inputs so as to create higher dimensional analogues of Thm.~\ref{thm:MainResult}.
Consider, for example, the image of Fig.~\ref{fig:MultiD} generated by $Y(s,t) = X_1(s)\cdot X_2(t)$ for two realizations of Eqn.~\ref{eq:ModelSimple}.
The 0-dimensional persistence diagram histogram is shown to the right, and, as with the previous data shown in this paper, there is a clear distinction between the points.
Since there are 35 points above a threshold of 8 in the histogram, we can conclude that there are  36 clusters in the image, which can be confirmed by inspection.
Thus, we hypothesize that this method is quite useful in higher dimensional applications, although such an application is still an open question for future research.

\begin{figure}[tb]
	\centering
	\includegraphics[draft =False, height = 2in]{MultiD-Image}
	\includegraphics[draft = False, height = 2in]{MultiD-PersDgm}
	\caption{An example of a higher dimensional analogue of the given method for pulse counting.  The image is a product of two realizations of Eqn.~\ref{eq:ModelSimple} and the histogram shows the resulting 0-dimensional persistence diagram.  The fact that there is a distinct split between the points in the diagram means that we can still use the high-persistence points to count the number of clusters seen at left.}
	\label{fig:MultiD}
\end{figure}

\blfootnote{The data files, code, and experimental parameters can be found at the gitlab repository \url{https://gitlab.msu.edu/TSAwithTDA/TDA-for-true-step-detection-in-PWC-signals}.}

\blfootnote{The authors acknowledge the help of David Petrushenko in setting up the lathe for the experiments.}

redpajama_set_name: RedPajamaArXiv


text:
Reaction mass of (3R)-3-[(1R)-4-methyl-3-cyclohexen-1-yl]butanal and (3S)-3-[(1R)-4-methyl-3-cyclohexen-1-yl]butanal
26-Nov-16 to 13-Jan-17
The study was conducted in accordance with international guidelines and in accordance with GLP. All relevant validity criteria were met.
EU Method C.2 (Acute Toxicity for Daphnia)
- Principle of test: The test was modified according to the OECD Series on Testing and Assessment Document no. 23 on aquatic toxicity testing of difficult substances (Guidance document on aquatic toxicity testing of difficult items and mixtures, OECD series on testing and assessment number 23, December 14, 2000).
- Short description of test conditions: water accomated fractions were prepared to create a series of loading rates to be tested.
- Parameters analysed / observed: See below.
- Concentrations: Every tested concentration and the control
- Sampling method: For sampling 4.0 mL from the approximate centre of the test vessels was taken at the start and end of each 24 hour renewal period over 48 hours (i.e. at 0 hours freshly dosed medium was analysed, 24 hours old medium and freshly dosed medium was analysed and at 48 hours old medium was analysed only). At the end of each exposure period the replicates were pooled at each concentration before sampling.
- Sample storage conditions before analysis: The samples were stored in a freezer (<-15 °C) until analysis stability at this storge temperature as been previously confirmed.
PREPARATION AND APPLICATION OF TEST SOLUTION (especially for difficult test substances)
Test medium used was Adjusted ISO medium.
- Method: The main test was conducted at 1.0, 1.8, 3.2, 5.6 10 % of a 100 mg/L saturated solution. Test solutions were prepared from a stock of saturate solution. The solution was obtained by stirring 100 mg/L of test item in the test medium for 2 days. This was followed by a 1 hour settling period. After this time the soluble fraction was siphoned from the vessel for use as the test medium.
- Eluate: N/A
- Differential loading: N/A
- Controls: A control consisted of the test medium only.
- Chemical name of vehicle (organic solvent, emulsifier or dispersant): N/A
- Concentration of vehicle in test medium (stock solution and final test solution(s) or suspension(s) including control(s)): N/A
- Evidence of undissolved material (e.g. precipitate, surface film, etc.): analytic, gas chomatograph of main constituents.
- Common name: Daphnia magna
- Strain/clone: N/A (In-house culture;
- Justification for species other than prescribed by test guideline: N/A (guideline species)
- Source: In-house laboratory culture with a known history (Stocks were kept in Elendt M7 medium and fed daily with fresh water algae. After 7 days of cultivation half of the medium twice a week, cultures were not allowed to exceed an age of 4 weeks).
- Age of parental stock (mean and range, SD): Daphnids originated from a healthy stock, 2nd to 5th brood, showing no signs of stress such as mortality >20%, presence of males, ephippia or discoloured animals and there was no delay in the production of the first brood. Parental daphnids were more than two weeks old.
- Feeding during test: None
- Food type: N/A
- Amount: N/A
- Frequency: N/A
- Acclimation period: N/A
- Acclimation conditions (same as test or not): ISO medium is used instead of Elendt M7 medium
- Type and amount of food: N/A
- Feeding frequency: N/A
- Health during acclimation (any mortality observed): N/A
QUARANTINE (wild caught)
- Duration: N/A
- Health/mortality: N/A
METHOD FOR PREPARATION AND COLLECTION OF EARLY INSTARS OR OTHER LIFE STAGES: For the test selection of young daphnids with an age of < 24 hours, from parental daphnids of more than two weeks old.
Remarks on exposure duration:
Consistent with guideline requirement.
180 mg/L CaCO3
8.9 to 9.6 mg/L
Conductivity:
Nominal concentrations were based on a percentage of a saturated solution. The saturated solution was obtained by dissolving 100 mg/L of test item in test medium for 48 hours, whilst being stirred continuously. After 48 hours the vessel was allowed to settle for 1 hour. At this point the soluble fraction was removed. Using this Saturated solution (and ensuring no solids were present by using the Tyndalls effect) concentrations of 1.0, 1.8, 3.2, 5.6 and 10 % were made.
Analysis of the samples taken at the start of the first renewal period showed measured concentrations of 0.76, 1.5, 2.5, 4.2 and 7.6 mg/L at 1.0, 1.8, 3.2, 5.6 and 10% of the SS at 100 mg/L, respectively. All concentrations remained stable during the first renewal period (93-100% of initial at the end of the renewal period). At the start of the second renewal period measured concentrations were 0.88, 1.6, 2.8, 4.7 and 8.4 mg/L at 1.0, 1.8, 3.2, 5.6 and 10% of the SS at 100 mg/L, respectively. All concentrations remained stable during the second renewal period (86-92% of initial at the end of the renewal period). Therefore, the effect parameters were based on the average of the initial measured concentrations that were calculated to be 0.82, 1.5, 2.7, 4.4 and 8.0 mg/L.
Firstly a combined limit/range finder test was conducted in order to determine if 1) a definitive test was required, and/or 2) what concntration range should be used in the definitive test. Twenty daphnids per concentration (four replicates, five daphnids per replicate) were exposed to a control and a saturated solution at 100 mg/L at 100 %. The test was performed under static conditions (i.e. no renewal of test solutions), ten daphnids per concentration (two replicates, 5 daphnids per replicate) were also exposed to 1.0 and 10 % of the saturated solution. Dissolved oxygen concentrations and pH were only measured in the control and the highest test concentration. The test was conducted in Adjusted ISO medium.
Test medium used was Adjusted ISO medium. The main test was conducted at 1.0, 1.8, 3.2, 5.6 10 % of a 100 mg/L saturated solution. A control consisted of the test medium only. At each concentration 20 daphnids were exposed split into 4 replicates of 5 dapnids each in 80 mL medium/ medium+test item. The test was conducted for 48 hours and renewel occured every 24 hours. Daphnids were not fed during the test, there was no aeration. The daphnids were introduced within 40 minutes of the test meidum preperation. Immobility was measured at 24 and 48 hours. Dissolved oxygen and pH was measured at the start and end of each renewal period, temperature was continuously monitored. The Spearman-Karber test was used to estimate effect levels due to deviations in monotonicity of the dataset. No trim was applied to reflect a worst-case EC50 value.
The test was considered valid if:
- Control daphnid immobility did not exceed 10 %, and no signs of disease or stress were displayed (i.e. surface trapping, unusual behaviour and discolouration).
- Dissolved oxygne within the medium stayed at >= 3 mg/L in all vessels.
meas. (geom. mean)
- Behavioural abnormalities: In the control one daphnid was found surface trapped in one replicate. In one replicate for both 10 and 100 mg/L of test material in one replicate, 4 and 2 daphnids were found to be surface trapped respectively.
- Observations on body length and weight: N/A
- Other biological observations: N/A
- Mortality of control: No mortality
- Other adverse effects control: surface entrapment of one daphnid.
- Abnormal responses: surface entrapment in 2 of the upper connctrartions.
- Any observations (e.g. precipitation) that might cause a difference between measured and nominal values: no.
- Effect concentrations exceeding solubility of substance in test medium: no.
For the range finder/limit test the accuracy target fell outwith the concentration criterion for 0.1 mg/L (i.e. 67 %). However, for 100 mg/L and for the definitive test the recovery/accuracy of the test item measurements were within the criterion (70-110%) and ranged from 82-93 % and therefore did not effect the validity of the final definitive test. During the definitive test the test medium measurements were of an acceptable level and fell within the criterion of 70-110 %.
No undissolved particles were observed in the test solution stock (using the Tyndall effect). Validity criteria for the test were met.
Measured concentrations in the definitive test were 0.76, 1.5, 2.5, 4.2 and 7.6 mg/L at 1.0, 1.8, 3.2, 5.6 and 10% of the saturated solution at 100 mg/L, respectively. All concentrations remained stable during the first renewal period (93-100% of initial at the end of the renewal period). At the start of the second renewal period measured concentrations were 0.88, 1.6, 2.8, 4.7 and 8.4 mg/L at 1.0, 1.8, 3.2, 5.6 and 10% of the SS at 100 mg/L, respectively. All concentrations remained stable during the second renewal period (86-92% of initial at the end of the renewal period). Therefore, the effect parameters were based on the average of the initial measured concentrations that were calculated to be 0.82, 1.5, 2.7, 4.4 and 8.0 mg/L.
All daphnids exposed to 8.0 mg/L became immobilized within 24 hours of exposure. In addition, 55% of the daphnids exposed to 4.4 mg/L became immobilized, while no immobility was observed at any of the lower concentrations and the control.
After 48 hours of exposure immobility was observed at all test concentrations. In the concentrations up to and including 2.7 mg/L immobility was below 50%, while immobility in concentrations of 4.4 mg/L and higher was above 50%.
For full results see tables in results section.
- Results with reference substance valid? yes, potassium dichromate was used and the test with the validity criteria as set within the guideline.
- Relevant effect levels: EC50 at 24 and 48 hours
- Limit test: no
- Dose-response test: yes
- ECx: The 24h-EC50 was 4.4 mg/L with a 95% confidence interval ranging from 3.9 to 5.0 mg/L. The 48h-EC50 was 2.2 mg/L with a 95% confidence interval ranging from 1.8 to 2.6 mg/L.
- Other: N/A
The 24h-EC50 was 4.4 mg/L (95% confidence interval between 3.9-5.0 mg/L).
Number of introduced daphnids and incidence of immobility in the final test
Time (h)
Average initial concentration Reaction mass of (3R)-3-[(1R)-4-Methyl-3-cyclohexen-1-yl]butanal and (3S)-3-[(1R)-4-Methyl-3-cyclohexen-1-yl]butanal (mg/L)
Total introduced
Total immobilised
[ ]: number of daphnids observed trapped at the surface of the test solutions. These organisms were reimmersed into the respective solutions before recording of mobility.
pH and oxygen concentrations (mg/L) during the final test
Average initial conc. Reaction mass of (3R)-3-[(1R)-4-Methyl-3-cyclohexen-1-yl]butanal and (3S)-3-[(1R)-4-Methyl-3-cyclohexen-1-yl]butanal
(mg/L)
Start (t=0 h)
t=24h old
t=24h fresh
End (t=48 h)
Concentrations of the test item in test medium - final test
Time of sampling
[hours]
Date of sampling
Percentage of Saturated solution
[%]
Analysed concentration
[mg/L]
Relative to
(old)
(fresh)
The 48h-EC50 of the test item to Daphnia magna was 2.2 mg/L (95% confidence interval between 1.8-2.6 mg/L).
Acute Toxicity Study in Daphnia magnawith Reaction mass of (3R)-3-[(1R)-4-Methyl-3-cyclohexen-1-yl]butanal and (3S)-3-[(1R)-4-Methyl-3-cyclohexen-1-yl]butanal.
The study procedures described in this report were based on the OECD guideline No. 202, 2004. In addition, the procedures were designed to meet the test methods of the CommissionRegulation (EC) No 440/2008, Part C.2, 2008 and the OECD series on testing and assessment number 23, 2000.
The batch of Reaction mass of (3R)-3-[(1R)-4-Methyl-3-cyclohexen-1-yl]butanal and (3S)-3-[(1R)-4-Methyl-3-cyclohexen-1-yl]butanal tested was a colourless liquid with a purity of 99.6% (sum of 2 diastereomers). The test item was not completely soluble in test medium at the loading rate initially prepared.
A semi-static final test was performed based on the results of a preceding static combined limit/range-finding test. An initial stock solution at 100 mg/L was prepared daily by adding measured amounts of the test item to test medium and mixing for 2 days to achieve an equilibrated concentration of dissolved constituents in the aqueous phase. Following cessation of mixing, and a 1 hour period of settling, the saturated solution (SS) was siphoned out and checked for tyndall effect, using a Laser pen. The clear and colourless SS was used as a stock solution. Lower concentrations were obtainedviaserial dilution of the SS in test medium.
Twenty daphnids per group (four replicates, five daphnids per replicate) were exposed to a control and to 1.0, 1.8, 3.2, 5.6 and 10% of the SS prepared at 100 mg/L. The total exposure period was 48 hours and test solutions were renewed after 24 hours of exposure.Samples for analytical confirmation of exposure concentrations were taken at the start and at the end of both renewal periods.
The study met the acceptability criteria prescribed by the study plan and was considered valid.
The 48h-EC50was 2.2 mg/L (95% confidence interval between 1.8 and 2.6 mg/L).
48 h EC50 (Daphnia magna) = 2.2 mg/L, OECD 202 Daphnia sp. acute immobilisation test, (Anon. 2017)
Fresh water invertebrates
Effect concentration:
The study procedures described in this report were based on the OECD guideline No. 202, 2004. In addition, the procedures were designed to meet the test methods of theCommissionRegulation (EC) No 440/2008, Part C.2, 2008 and the OECD series on testing and assessment number 23, 2000.

redpajama_set_name: RedPajamaCommonCrawl


Yep. Life steamrolled me. Again.
So, here's a scattered dump to bring you up to speed.
How long has it been? Two years… ugh….
Dogs. So much with the dogs. New titles in Barn Hunt, Weight Pull, Rally Obediene, Conformation, and progress made on more.
Halo earning her UKC Grand Show Champion title in Tennessee, October 2016.
Ranger won the NALC B-Bay Top Ten Day of Trial buckle in 2016. This was a huge pick me up because the year before he disqualified on his Top Ten run (though Halo had his back and ended up with 2nd place in the Top Ten trial).
Ranger and Halo had their babies in August 2016. I haven't mentioned that here. There's a lot of madness, proud moments, and serious heartbreak involved with that and I'll tell those stories as I am ready.
Halo, Ranger, Drama, and Trekker after a weekend of shows in Kentucky (April 2017).
One of those babies is staying here. He's called Trekker (for Ranger, and a great-grand sire, Rambler). He's super sweet and a little soft tempered, like Halo, but looks like a copy of Ranger. It's funny how that worked out. He is eager to learn and happy to please. He just got his UKC Grand Show Champion title along with some Group placements along the way.
One of the puppies, Drama, came back to me due to some circumstances changing. The hope was to send her to my mentor to go be a working dog in the fall, but she's doing really well here, so if I can convince Eric there's room for a fourth dog she'll stay and be a performance dog. She also recently earned her UKC Grand Show Champion title along with Group placements, a Best in Show, and a Reserve Best in Multi Breed Show. That still hasn't sunk in. Like Trek, she has a nice medium between Ranger and Halo's temperaments. Not too soft and not too distracted.
Jobs. Got a new one. As much as I loved training dogs, the pay just wasn't what I needed to maintain my vehicle, buy dog food, buy groceries, etc. The new job: I'm okay at it, I like it well enough, and it pays the bills. I get to work a lot of overtime, which is helping me catch up on things that I let slide while I was working part time, but that also means less trail time (it's a double-edged sword).
I started hiking the Laurel Highlands Trail in Pennsylvania. That was my first real backcountry trip after Halo's snake bite. It got cut short because I got sick on the trail. I want to go back and finish it. Thankfully it's only about a 5 hour drive from home, so on a long weekend I can knock out a few sections. I may not be able to thru-hike it (because, seriously, 4 dogs is crazy for logistics on something like this), as originally planned, but I can finish it nonetheless.
I completed the North Country Trail Hike 100 Challenge for 2016 and am working on it for 2017.
My grandmother died in October 2016. It's something I need to talk about as she's the one who taught me a lot of skills that have helped me in the outdoors. She never took me camping outside of an RV style lot, but she taught me lots about growing and preserving food, fixing things, sewing, knitting, and more. Oh yeah, and she walked part of the Natchez Trace many, many years ago. Unfortunately no one has any documentation on it. I didn't find out until well after she was unable to tell me more.
So, that's the short, short version of a whirlwind. I have a list of DIY projects to complete and share, some training ideas, and a few other things that have been on the back burner for far too long.


text:
Q: updating id to max(id)+1 can someone please help me with the below mysql query:
I want to build a query like:
UPDATE users
SET ref_id = (select max(ref_id)where `role_id`=5) +1
WHERE user_id =102
AND `role_id`=5

A: where your FROM clause in subquery???
UPDATE users
SET ref_id =
    (select max(ref_id) FROM ???? where role_id=5) + 1
WHERE user_id =102 and role_id=5

A: Ok I tried a similar request and I had this MySQL error :
1093 - You can't specify target table 'my_table' for update in FROM clause

Try using the following request :
UPDATE `users`
SET
`ref_id` =
(
 ( SELECT max_id FROM ( SELECT MAX(ref_id) AS max_id FROM users WHERE `role_id`= 5) AS sub_selected_value )
 + 1
)
WHERE `user_id` = 102 AND `role_id` =5

Please keep in mind that may not be the most efficient solution if performance matters because it uses temporary tables.

redpajama_set_name: RedPajamaStackExchange


Vehicle wraps increase visibilty dramatically by turning a car into a billboard that is advertising all around town. Could you benefit from exposure to 1000's of people per day?
Copyright © 2003 Creative Color Imaging Studio. All rights reserved.


I haven't posted my Friday Thoughts for a while. I' don't know about you, but it's been a busy summer. Now that the kids are starting back to school, maybe I'll find some time for writing. Sam Henry started 3K at St. James on Monday, but Clara doesn't start Wilson Hall kindergarten until the 27th. She's a little jealous of her brother right now!
One of the questions that I've been getting recently is about the seeming divergence of the economy and the stock markets. The economy seems to be doing well, yet the markets seem to be struggling this year and most investment accounts have seemed to go nowhere. How can that be?
I will agree that the US economy is doing well. Unemployment is low, economic activity is up, and businesses are doing well. Profits for the companies in the S&P 500 Index are at record highs. This is all good news and we should enjoy the good times and dance while the music is playing.
But, the stock market tends to be forward looking. Investors are pricing in future earnings, not today's earnings. The stock markets had their initial sell off earlier this year due to concerns about the impact of rising interest rates. The reality is that, due to the Great Recession, we have seen actions by the Federal Reserve over the last 8+ years that we've never seen before. They are now backing off of these unprecedented actions and investors have no idea what the impact will be.
With the huge amount of outstanding debt, there will be an impact from rising interest rates. With trillions of dollars in debt, every tick up in interest rates adds to the carrying cost to the debtor. While we are still at low rates, in comparison to rates 25 or 30 years ago, these higher carrying costs will hit company profits.
It does seem that easing of financial stimulus is impacting some overseas businesses already. We're seeing stocks in developing countries like China struggling recently. There are a lot of complicated reasons for this, in addition to rising interest rates. But I also think that we can't discount the impact of some of the rhetoric coming from President Trump and these countries reaction to it. The threats of tariffs are seemingly impacting manufacturing and sales overseas and helping the same here. This is not what the politicians in Washington or the media expected and it may not continue, but it I'm never shocked to see the pundits get the reality of middle America wrong.
I will say that I've been fearful of rising interest rates pushing us closer to a recession by next year. However, as companies have been releasing their quarterly results over the last month or so, I've begun to think that this may be further out than I initially thought. Profits are higher than I expected, and companies are beginning to talk about expansion, growth and spending. The tax cuts and reduced regulations are often being cited as reasons for the renewed optimism.
I still believe that a well diversified portfolio of US & International stocks and bonds is the best way to enjoy this economic good news while protecting from an eventual recession. I expect the markets to continue with the same volatility seen so far this year. We may even see another sell off. The reality is - that's pretty normal. You just need to be sure that your blend of those stocks and bonds has a risk profile that matches your expectations and comfort level.
If you're wondering if your portfolio really does match your comfort level, I have some great tools that can help. Feel free to give me a call or simply reply to the e-mail.
I hope that you have a great weekend. After this one, we only have one more weekend without college football!!
The S & P 500 Index is an unmanaged index that is generally considered representative of the U. S. stock market. The performance of an unmanaged index is not indicative of the performance of any particular investment. Investors cannot invest directly in an index.
Diversification does not guarantee against loss; it is a method used to manage risk.
International investing, especially in emerging market economies, involves special risks including country, currency, and geo-political risk, as well as, increased volatility of foreign securities and differences in accounting practices.


What does an award-winning craft beer have to do with small business marketing? Well, if the beer happens to be Pliney the Elder from the Russian River Brewing Company, it makes for a great case study about how to use scarcity marketing to drive up demand for your products or services.
Scarcity marketing is when you motivate people to buy something (or buy more of something, or buy it sooner than they otherwise would have) by creating a scarcity of it. The most commonly used example would be the "limited time only" offer or sale that many businesses frequently advertise.
In the case of the Pliney the Elder beer, what happened was that as it started winning awards (it's won the title of best beer in America from the American Homebrewer's association for seven years in a row), the demand for the beer increased dramatically, but the production volume couldn't keep up with the demand. The result was that it became almost impossible for people to get their hands on a bottle of this beer.
As it became harder and harder to find the beer, when people did run across it they wanted to buy it in larger quantities since they didn't know how long it would be before they could get more. This, of course, drove up the demand even more.
Beer stores soon started limiting people to one six-pack or even one bottle of the beer per customer. That's when things really started to get crazy. People would literally stand in line on the days when the shipments of the beer were due to arrive at a store to make sure they got their bottle. Some people even started following the beer delivery trucks from store to store so they could buy more of it, which led to the beer being delivered in unmarked trucks in some cases.
All of this basically cemented the beer's legendary status. It really didn't even matter what the beer tasted like; people just talked about it because of how hard it was to get, which of course just made people want it more.
Now, unless you sell an addictive substance, you will probably not be able to create that kind of demand for your products or services. However, with a little bit of creativity you can still use scarcity marketing effectively.
In my most recent episode of my podcast, I give you some ideas about how to do this, as well as some examples of how I've used scarcity marketing in my own business. Use the player below to listen to the episode, and subscribe to the podcast to get future episodes as soon as they are published.


text:
Зухдийят ( — стихи об аскетизме) — жанр классической арабской поэзии, представленный короткими лирико-философскими произведениями. Иногда термин «зухдийят» используется для определения аналогичного жанра персидско-таджикской поэзии.

Жанр начал распространяться в арабской поэзии в VIII—IX веках.

Основная тематика жанра — бренность бытия, суетность жизни, непредсказуемость судьбы, разочарование в людях, крушение надежд, призыв к духовному самосовершенствованию, восхваление благочестия и целомудрия.

Обычно произведения этого жанра объединялись в циклы самими поэтами или позднее составителями их сборников (диванов). Известны стихотворения Абуль-Ала аль-Маарри, Абу-ль-Атахийи, Абу Нуваса, Абу Таммама, Омара Хайяма и др. поэтов.

Жанр сохранился до наших дней в эпигонской религиозной поэзии и в виде подражаний известным поэтам.

О жизни (подражание Хайяму)

И как бы ни был ты умён,
Постигнув суть былых времён,
Проникшись мудростью Востока, —
От жизни надо ждать урока…

(П. Густерин).

Примечания

Литература

Твёрдые формы
Арабско-персидская метрика
Литература на персидском языке
Таджикская литература
Поэтические жанры
Персидская поэзия
Арабская поэзия
Литературные жанры

redpajama_set_name: RedPajamaWikipedia


In life we will all eventually be faced with some sort of tragedy. The loss of a loved one, sickness, pain, or heartbreak. Some of us give up during these tough times, while others fight back, becoming even stronger than before. We all love to hear stories of people who have turned their tragedy into triumph, and such is the story of Tanisha D. Mackin who shares her inspiring story with us in a exclusive Writer's Life interview.
Also check out our other exclusive interviews, books by talented indie authors and tips from some of the most sought after best-selling and award-winning indie authors and publishers around!!!