\section{Introduction}

Hawkes processes \citep{hawkes_spectra_1971} are a class of point processes that are used to model event data when the events can occur in clusters or bursts. Typical examples include earthquakes  \citep{omi_estimating_2014}, stock transaction \citep{rambaldi_role_2017}, crime \citep{Shelton}, and social media \citep{lai_topic_2016, mei_neural_2017}.

The Hawkes process is defined by a conditional intensity function $\lambda(\cdot)$ which controls the probability of events occurring at each interval in time, based on the previous history of the process. The conditional nature of the intensity function allows the intensity to increase for a short period of time whenever an event occurs, which results in a higher probability of further events occurring, hence creating event clusters and bursts.

Typically $\lambda(\cdot)$ is assigned a parametric form which allows for a relatively straightforward estimation using maximum likelihood or Bayesian methods \citep{Veen_2008_estimation,rasmussen_bayesian_2013}. Alternatively, a nonparametric estimation of the intensity function has been proposed for a variety of settings: stochastic intensity functions \citep{donnet_nonparametric_2018} or using kernel methods \citep{choi_nonparametric_1999}, LTSM neural networks \citep{mei_neural_2017}, and GANs \citep{xiao_wasserstein_2017}.

Most applications of the Hawkes process assume that the entire history of events has been accurately observed. However, many real world applications suffer from missing data where some events are undetected \citep{mei_imputing_2019}, or from noisy data where the recorded event times are inaccurate \citep{trouleau_learning_2019}. We refer to this as data distortion, and it can occur for several reasons. For example, in earthquake catalogues it is well known that the occurrence of large earthquakes has a masking effect which reduces the probability of subsequent earthquakes being detected for a period of time \citep{helmstetter_comparison_2006, omi_estimating_2014, arcangelis_overlap_2018}. Alternatively, event data may simply not be available for a certain interval of time, such as in a terrorism data set considered by \citet{tucker_handling_2019}.

Distorted (e.g. missing or noisy) data causes serious problems for Hawkes processes. If the model parameters are learned using only the observed data then the estimation of $\lambda(\cdot)$ may be severely biased. As such, a principled learning algorithm needs to consider the impact of the distortion.  So far, there has only been limited work on learning Hawkes processes in the presence of distorted data. The main exception to this is when the distortion takes the form of gaps in the observations where no events are detected at all  for a certain period \citep{Le, Shelton}. In this context, \citet{tucker_handling_2019} develop a Bayesian estimation algorithm which uses MCMC to impute missing events, and a similar approach is proposed by \cite{mei_imputing_2019} using particle smoothing. \citet{linderman_bayesian_2017} view the true generating process as a latent variable, which can be learned through sequential Monte Carlo techniques. Other examples look at specific instances of censored data \citep{xu_learning_2017} or asynchronous data \citep{upadhyay_deep_2018, trouleau_learning_2019}

In this paper, we present a more general approach for estimating Hawkes processes in the presence of distortion, which can handle a much wider class of distortion scenarios, including the case of gaps in the observed data, the case where there is a reduced probability of detecting events during some time period, and the case of noise in the recorded observation times. Our approach assumes the existence of a general distortion function $h(\cdot)$ which specifies the type of distortion that is present. The resulting Hawkes process likelihood is computationally intractable, since the self-excitation component involves triggering from the (unobserved) true event times, which must be integrated out to give the likelihood of the observed data. To solve this problem, we propose a novel estimation scheme using Approximate Bayesian Computation \citep[ABC,][]{marin_approximate_2012} to learn the Hawkes intensity in the presence of distortion. The resulting algorithm, ABC-Hawkes, is based on applying ABC using particular summary statistics of the Hawkes process, with separate convergence thresholds for each statistic.

The paper is organized as follows. In Section~\ref{sec_problemoverview} we introduce the Hawkes process and the distorted data setting. Section~\ref{sec_ABC} summarizes ABC and introduces the ABC-Hawkes algorithm for  parameter learning in the presence of distorted data. Section~\ref{sec_realdata} provides experimental results using Twitter data and simulations. We finish with a discussion of our work and contributions, as well as comments on future research. The \textsf{R} code for our analyses can be found in the supplementary material.

\section{Problem Overview} \label{sec_problemoverview}

In this section we define the Hawkes process and propose the implementation of distortion functions. We highlight the problem arising from missing or noisy events, which causes the Hawkes likelihood function to become computationally intractable.

\subsection{Hawkes Processes} \label{sec_Hawkes}

The (unmarked) Hawkes process introduced by \citet{hawkes_spectra_1971} is a self-exciting point process which models a collection of event times $Y = (t_i)_{i = 1}^N$. The occurrence of each event causes a short-term increase in the underlying point process conditional intensity function $\lambda(\cdot)$, known as self-excitation. This naturally produces temporal clusters of events, and it is hence an appropriate model for events which occur in bursts. More formally, a Hawkes process is a point process defined on the interval $[0, T]$  with a conditional intensity function:
\begin{equation}
    \lambda(t| H_t,\theta) = \lambda_0(t|\theta) + \sum_{i: t > t_i}\nu(t-t_i|\theta)
    \label{eqn:hawkes}
\end{equation}
where $\theta$ is a vector of model parameters, and $H_t = \{t_i | t_i <t)$ denotes the set of events which occurred prior to time $t$. Here, $\lambda_0(t) > 0$ is the background intensity which defines the equilibrium rate at which events occur. The excitation kernel  $\nu(z)>0$ controls how much the intensity increases in response to an event at time $t$.  Typically, the excitation kernel is monotonically decreasing, so that more recent events are more influential. The choice of kernel varies from application to application. A typical choice for an unmarked point process is the exponential kernel \citep{NIPS2012_4834, rasmussen_bayesian_2013, Shelton}:
\begin{equation}
    \nu(z|\theta) = K \beta  e^{- \beta z}, \quad \theta = \{K, \beta\} \label{eq_exponential}.
\end{equation}

The Hawkes process can also be interpreted as a branching process \citep{hawkes_cluster_1974}, where ``immigrant'' events are  generated from the background process with intensity $\lambda_0(t)$, with each event spawning an additional off-spring process with intensity $\nu(z)$ which produces further events, and so on.

For a set of observations $Y$ the likelihood of a Hawkes process is given by \citep{daley_introduction_2003}:
\begin{equation}
    p(Y | \theta)=\prod_{i=1}^N \lambda\left(t_{i} | \theta \right) e^{-\int_{0}^{\infty} \lambda\left(z | \theta \right) \,d z} \label{eq_etas_lik}
\end{equation}
where $\theta$ is the vector of unknown model parameters which must be estimated in order to fit the Hawkes process to the data. For ease of exposition, we will assume without loss of generality that the background intensity $\lambda_0(t) = \mu$ is constant, and that the excitation kernel is exponential. In this case,  $\theta =(\mu, K, \beta)$. However nothing in our algorithm requires these assumptions, and our method is equally applicable to any other choice of background rate or kernel function.

\subsection{Distorted Data} \label{sec_missing_data}

In many applications, the observed data will be distorted, i.e. noisy or containing  missing events. This is often due to data collection issues which result in some events being undetected or observed with error. Our proposal is to model this distorted data using a distortion function $h(\cdot)$, and now present some examples of specific choices of this function.

A common type of data distortion is \textbf{missing data} where a subset of the data is not observed. This is a well-known phenomenon which affects the use of Hawkes processes in earthquake forecasting since seismic detectors lose their ability to detect smaller earthquakes in the immediate aftermath of large earthquakes \citep{omi_estimating_2014}. In other examples, data from a certain period might simply have been lost, as is the case in the terrorism data set discussed by \cite{tucker_handling_2019}.

In the case of missing data, let $h(t)$ be a detection function specifying the probability that an event occurring at time $t$ will be successfully detected, and hence which will be present in the observed data $Y$. The observed data can be viewed as having arisen from the following generative process: First, a set of events $(t_1, \ldots, t_K)$ are generated from a Hawkes process with some intensity function $\lambda(\cdot)$. Then, for each event $t_k$ for $k = 1, \dots, K$, let $D_k = 1$ with probability $h(t_k)$ and $D_k = 0$ with probability $1-h(t_k)$. The observed data is then the collection of events for which $D_k = 1$, so that $Y = \{t_k | k: D_k = 1\}$. Note that this formulation of missing data is quite general and includes the classic ``gaps in the data'' scenario as a special case, since this is equivalent to setting $h(t) = 0$ during the period where gaps occur, and $h(t)=1$ elsewhere. However, this specification is highly flexible and also covers scenarios where events are not guaranteed to be missing for a certain period of time, but are instead missing with a (possibly time-dependent) non-zero probability, as in the earthquake scenario.

When data is potentially missing, it is very challenging to learn the $\theta$ parameter of the Hawkes process. If the Hawkes process did not have a self-exciting component, then the likelihood function in the presence of missing data would be obtained by assuming that the data came from a modified point process with intensity $r(t) = \lambda(t)h(t)$, i.e. the product of the intensity function and the detection function. The parameters of $r(\cdot)$ could then be learned using a standard method such as maximum likelihood or Bayesian inference. However, when working with Hawkes processes, the situation is substantially more complex. The main issue is that undetected events will still contribute to exciting the process intensity, i.e. the summation in Equation~\eqref{eqn:hawkes} needs to be over both the observed and unobserved events. The resulting likelihood function hence depends on both the set of observed events $Y$ and the set of unobserved events which we denote by $Y_{u}$. This requires integrating out the unobserved events, to give the likelihood function:
\begin{align}
    p(Y  | \theta) \propto
    \int  p(Y, Y_{u} | \theta) \,
 \prod_{t_i \in Y} h(t_i) \prod_{t_l \in Y_{u}} (1- h(t_l)) \, d Y_{u} \label{eqn:missing}
\end{align}
where  $Y_u = \{t_k | k: D_k = 0\}$ denotes the set of missing events. Due to the integral over the unknown number of missing events, this likelihood function is intractable and cannot be evaluated.

For \textbf{noisy data} (rather than missing data), we use a similar approach except that the distortion function $h(t)$ will now specify  the time at which an event is observed to have occurred, give that it truly  occurs at time $t$. For example, $h(t) = t + \varepsilon_t$ where $\varepsilon_t \sim N(0,\sigma^2_t)$ would be appropriate in a setting where the observation times are corrupted by Gaussian noise, while  $h(t) = t + c$ for a constant scalar $c$ would be used when there is a fixed delay present in the recording of all observation times. Such a synchronization example is studied by \citet{trouleau_learning_2019}. As in the case of missing data, this leads to an intractable likelihood function since the excitation in the summation from Equation~\eqref{eqn:hawkes} depends on the true observation time $t_i$ which is unknown.

The distortion function may be parameterized by a vector of parameters $\xi$ which can denote, for example, the detection probability in the case of missing data, or the noise variance $\sigma_t$ in the case of noise. In some situations these parameters will be known due to knowledge of the underlying machinery used to detect the events. In other situations, they may be learned from the data.

Since all the above data distortion scenarios make direct learning of the Hawkes process impossible due to the intractable likelihood, we now propose a novel learning scheme for Hawkes processes with distorted data based on Approximate Bayesian Computation which we refer to as ABC-Hawkes.

\section{Approximate Bayesian Computation} \label{sec_ABC}

ABC is a widely studied approach to Bayesian inference in models with intractable likelihood functions \citep{beaumont_approximate_2002, marjoram_markov_2003,marin_approximate_2012}. We will now review the general ABC framework and then present a version of ABC for sampling from the posterior distribution of the Hawkes process parameters in the presence of distorted data.

Bayesian inference for a parameter vector $\theta \in \Theta$ assumes the existence of a prior $\pi(\theta)$ and a likelihood function $p(Y | \theta)$ for data $Y \in \mathcal{Y}$, with parameter inference based on the resulting posterior distribution $\pi(\theta | Y)$. Traditional tools for posterior inference such as Markov Chain Monte Carlo (MCMC) require the evaluation of the likelihood function and therefore cannot be applied when the likelihood is intractable. In this case, however, it may still be possible to generate samples $Y^{(j)}$ from the model. ABC is an approach to parameter and posterior density estimation which only uses such generated samples, without any need to evaluate the likelihood \citep{beaumont_approximate_2002}.

The core idea of ABC is as follows: We assume that the observed data $Y$ has been generated by some (unknown) value of $\theta$. For a proposed value of $\theta^{(j)}$, we generate pseudo-data $Y^{(j)}$ from the model $p(Y|\theta^{(j)})$ in a way which does not involve evaluating the likelihood function. If $\theta^{(j)}$ is close to the real $\theta$, then we would also expect $Y^{(j)}$ to be `close' to the real (observed) data $Y$, as measured by similarity function. We can hence accept/reject parameter proposals $\theta^{(j)}$ based only on the similarity between $Y$ and $Y^{(j)}$ .

This algorithm crucially depends on how we measure similarity between data sets $Y$ and $Y^{(j)}$. Typically, low-dimensional summary statistics $S(\cdot)$ of the data are chosen and then compared based on some distance metric $\mathcal{D}(\cdot ,\cdot )$ \citep{fearnhead_constructing_2012}. A proposed parameter $\theta^{(j)}$ is then accepted if this distance is less than a chosen threshold $\epsilon$. Generally, this procedure will not target the true posterior $\pi(\theta | Y)$, but instead targets the ABC posterior $\pi_{ABC}(\theta | \mathcal{D}(S(Y) , S(Y^{(j)}) < \epsilon)$. However, if the statistics $S(\cdot)$ are chosen to be the sufficient statistics for the model parameters and $\epsilon \to 0$, then $\pi_{ABC}(\theta | \mathcal{D}(S(Y) , S(Y^{(j)}) < \epsilon) \to \pi(\theta | Y)$ \citep{marin_approximate_2012}. A direct implementation of this ABC procedure is based upon rejection sampling, where $\theta^{(j)}$ is proposed from the prior distribution \citep{pritchard_population_1999}. However this can be inefficient, so instead ABC-MCMC methods can be used which make proposals based on a Metropolis-Hastings kernel without the need to evaluate the likelihood function, which can lead to a higher acceptance rate for ABC \citep{beaumont_approximate_2002}.

In most realistic applications, it is not possible to choose a low-dimensional set of summary statistics which is sufficient for the parameter vector, since only the limited class of distributions that lie in the exponential family admit a finite dimensional set of sufficient statistics \citep{brown_fundamentals_1986}. Therefore, finding suitable summary statistics and an appropriate distance metrics for a particular model is non-trivial, and is a vital part of designing efficient ABC algorithms \citep{marin_approximate_2012}. Some authors construct summary statistics which are carefully tailored to their application \citep{aryal_fitting_2019}, while others present a semi-automatic way to constructing summary statistics \citep{fearnhead_constructing_2012}. \citet{bernton_approximate_2019} develop a general approach, that uses the Wasserstein Distance between the observed and synthetic data set, hence eliminating the need for summary statistics altogether.

\subsection{ABC-Hawkes Algorithm} \label{sec_ABC_pointprocess}

Our core idea is to use ABC to perform inference for the Hawkes process with distorted data, which circumvents the intractability of the likelihood function. This is made possible by the fact that simulating data from the distorted generative model is straightforward, and can be done by first simulating data from the Hawkes process with intensity function $\lambda(\cdot)$ which represents the true (unobserved) data and then distorting these events based on the distortion function $h(\cdot)$ as discussed in Section~\ref{sec_missing_data}, which gives the observed data $Y$. The simulation from $\lambda(\cdot)$ can be carried out using a standard simulation algorithm for Hawkes process such as the thinning procedure of \citet{ogata_lewis_1981}. The distortion of the data is then performed by applying $h(\cdot$) to each simulated data point, which introduces missingness and/or noise. For example in the case of gaps, this would consist of deleting the simulated observations which lie within the gap region, while for noise it would consist of adding on noise to the simulated data, as specified by $h(\cdot)$. The resulting observations are hence a realization of the Hawkes process with intensity function $\lambda(\cdot)$ that has been distorted through $h(\cdot)$.

For ABC-Hawkes we use a variant of the ABC-MCMC algorithm, as shown in Algorithm~\ref{alg_abc_MCMC}. This is an extension of the usual Metropolis-Hastings algorithm which essentially replaces the intractable likelihood function with an estimate based on the simulated data and can be shown to converge correctly to the ABC posterior  $\pi_{ABC}(\theta | \mathcal{D}(S(Y) , S(Y^{(j)}) < \epsilon)$ \citep{marjoram_markov_2003}.

\begin{algorithm}[tbp]
   \caption{ABC-Hawkes} \label{alg_abc_MCMC}
 \begin{algorithmic}
   \STATE {\bfseries Input:} observed data $Y$ where data is distorted according to a distortion function $h(\cdot)$,  the parameter prior $\pi(\cdot)$, the desired number of posterior samples $J$, a function to compute the $P$ summary statistics $S_1(\cdot),\ldots,S_P(\cdot)$, the $P$ threshold levels $\epsilon_p > 0$, and a Metropolis-Hastings transition kernel $q(\cdot | \cdot)$ \\
   \hrulefill
   \STATE{Initialise $\theta^{(0)}$}
   \FOR {$j=1$ {\bfseries to} $J$}
        \STATE{$\theta^* \sim q(\cdot | \theta^{(j -1)})$}
        \STATE{$ Z^{*} \sim p(\cdot | \theta^{*})$, where $p(\cdot)$ simulates from a Hawkes process}
        \STATE{$Y^{*} = h(Z^{*})$}
        \IF{$|S_p(Y^{*}) - S(Y)| < \epsilon_p$ for all $p = 1, \dots, P$}
            \STATE{With probability $min \left\{1, \frac{q(\theta^{(j-1)}|\theta^{*}) \pi(\theta^*)}{q(\theta^*|\theta^{(j-1)}) \pi(\theta^{(j-1)})}\right\}$ set $\theta^{(j)} = \theta^*$}
        \ELSE
        \STATE{Set $\theta^{(j)} = \theta^{(j-1)}$}
        \ENDIF
   \ENDFOR
   \STATE {\bfseries Output:} $(\theta^{(1)}, \dots, \theta^{(J)})$
  \end{algorithmic}
\end{algorithm}

The choices of summary statistics $S(Y)$ and corresponding threshold $\epsilon$ are crucial for the application of ABC \citep{marin_approximate_2012}. While the ABC literature offers a wealth of theory on summary statistics, their actual construction is less prominent and tends to be highly application-dependent. In the context of Hawkes processes, this is complicated by the non-i.i.d. structure of the data, which renders many existing approaches impossible as they require multiple (bootstrapped) samples of the original data set; such as using random forests to find summary statistics  \citep{pudlo_reliable_2016}, or utilizing a classifier or reinforcement learning to judge the similarity between data sets \citep{gutmann_likelihood-free_2018, li_learning_2018}. These approaches are not applicable here as only one data set is available and bootstrap sampling cannot be used due to the complex dependency structure of self-exciting point processes.

 While there has been some previous literature on ABC for Hawkes processes outside of the distorted data setting \citep{ertekin_reactive_2015, shirota_approximate_2017} we found that the presented summary statistics did not extend well to distorted data. Instead, through extensive simulations we have found a set of summary statistics which we have empirically found to accurately captures the posterior distribution of the Hawkes process parameters, and in the Experiments section we will provide evidence to support this. For ABC-Hawkes, the resulting summary statistics  $S(Y) = (S_1(Y), \ldots , S_7(Y)))$ we use are:

\begin{itemize}
    \item $S_1(Y)$: The logarithm of the number of observed events in the process. This is  highly informative for the $\mu$ and $K$ parameters, since $\mu$ controls the number of background events, while $K$ defines how much total triggering is associated with each event.
    \item $S_2(Y)$: The median of the event time differences $\Delta_i = t_i - t_{i-1}$ divided by the mean event time differences $\mathbb{E}[\Delta]$. This is highly informative for the parameters of the self-excitation kernel (e.g. $\beta$, for an exponential kernel).
    \item $S_3(Y) \dots S_5(Y)$: Ripley's $K$ statistic \citep{ripley_1977_modelling} for a window size of $(1, 2, 4)$. This counts the events that happen within the respective window-length of each other. We do not use a correction for the borders. This captures the degree of clustering in the event sequence and is hence informative for $K$ and the parameters of the excitation kernel.
    \item $S_6(Y), S_7(Y)$: The average of the $\Delta_i$ differences that lie above their $90\%$-quantile $\mathbb{E}[\Delta_i | \Delta_i > q_{90}]$ and below their median $\mathbb{E}[\Delta_i | \Delta_i < q_{50}]$. In extensive simulation studies we found that these complement the other statistics well and lead to an accurate approximation of the posterior distribution.
\end{itemize}

When using multiple summary statistics, careful consideration must be made when combining them together. We choose to work with a separate thresholds $\epsilon_p$ for each of the summary statistics. We set this to be a fraction of the empirical standard deviation of the summary statistic based on a pilot run of the simulation, such that $0.01-0.1$\% of the proposals are accepted \citep{vihola_use_2020}. We hence accept a proposed value $\theta^{(j)}$ only if $\mathcal{D}(S_p(Y), S_p(Y^{(j)}) < \epsilon_p$ for all $p$, using the absolute value function ($L_1$ norm) as the distance metric $\mathcal{D}(\cdot, \cdot)$.

In the case where the detection function $h(\cdot)$ is parameterized based on an unknown set of hyperparameters $\xi$, these can also be sampled from their posterior distribution at each stage in the above MCMC algorithm using standard Metropolis-Hastings methods.

\section{Experimental Results} \label{sec_realdata}

We now present experimental results to show the performance of the ABC-Hawkes algorithm. First, we will present evidence that the set of summary statistics we presented above capture most of the information in the parameter posterior distribution for the Hawkes process when distorting is not present. Next, we will investigate how accurately they allow the parameters to be estimated in the presence of distortion. To do this, we will manually insert data distortion into a simulated event sequences where we have access to the true event times. This allows us to compare the posterior distribution estimated by ABC-Hawkes on the distorted data to the ``true'' posterior which would have been obtained if we had access to the undistorted data.
\subsection{No-distortion Setting}

We first confirm whether the above ABC summary statistics accurately allows the posterior distribution to be estimated in a standard Hawkes process without distortion. We will then compare our approach to that of \citet{ertekin_reactive_2015} which is the only existing example we could find of applying ABC to Hawkes processes, although they do not consider the data distortion setting.

To investigate the capabilities of our algorithm to recover the true posterior distribution without distortion we generate three data sets and compare the posterior estimates from ABC-Hawkes to the ground truth from Stan. We use the following priors: $\mu \sim \mathcal{U}(0.05, 0.85)$, $ K \sim \mathcal{U}(0, 0.9)$, $ \beta \sim \mathcal{U}(0.1, 3)$. As shown in Figure~\ref{fig_post_proofofconcept} ABC-Hawkes can approximate the posterior distributions, both in location and shape, in this simulation study. We note that the overestimation of the posterior variance for $\beta$ in the first data set is an often observed issue in ABC stemming from a necessary non-zero choice of the $\epsilon_p$ threshold \citep{li_convergence_2017}.

\begin{figure}[t]
  \flushleft
   \begin{subfigure}{.09\textwidth}
      \flushright
      Data Set 1
  \end{subfigure}
  \begin{subfigure}{.28\textwidth}
      \centering
      \includegraphics[width=.99\linewidth]{figures/ProofofConcept/sim_data1_mu.pdf}
  \end{subfigure}
  \begin{subfigure}{.28\textwidth}
      \centering
      \includegraphics[width=.99\linewidth]{figures/ProofofConcept/sim_data1_K.pdf}
  \end{subfigure}
  \begin{subfigure}{.28\textwidth}
      \centering
      \includegraphics[width=.99\linewidth]{figures/ProofofConcept/sim_data1_beta.pdf}
  \end{subfigure} \\
  \begin{subfigure}{.09\textwidth}
      \flushright
      Data Set 2
  \end{subfigure}
  \begin{subfigure}{.28\textwidth}
      \centering
      \includegraphics[width=.99\linewidth]{figures/ProofofConcept/sim_data2_mu.pdf}
  \end{subfigure}
  \begin{subfigure}{.28\textwidth}
      \centering
      \includegraphics[width=.99\linewidth]{figures/ProofofConcept/sim_data2_K.pdf}
  \end{subfigure}
  \begin{subfigure}{.28\textwidth}
      \centering
      \includegraphics[width=.99\linewidth]{figures/ProofofConcept/sim_data2_beta.pdf}
  \end{subfigure}\\
  \begin{subfigure}{.09\textwidth}
      \flushright
      Data Set 3
  \end{subfigure}
  \begin{subfigure}{.28\textwidth}
      \centering
      \includegraphics[width=.99\linewidth]{figures/ProofofConcept/sim_data3_mu.pdf}
      \caption{$\mu$}
  \end{subfigure}
  \begin{subfigure}{.28\textwidth}
      \centering
      \includegraphics[width=.99\linewidth]{figures/ProofofConcept/sim_data3_K.pdf}
      \caption{$K$}
  \end{subfigure}
  \begin{subfigure}{.28\textwidth}
      \centering
      \includegraphics[width=.99\linewidth]{figures/ProofofConcept/sim_data3_beta.pdf}
       \caption{$\beta$}
  \end{subfigure}
  \caption{Undisturbed data posterior distributions. Each row uses a different simulated data set. Parameters $(\mu, K, \beta)$ are chosen as $(0.2, 0.5, 0.5)$, $(0.4, 0.3, 0.8)$, and $(0.3, 0.3, 1)$ for the three data sets. The black curve shows the true posterior estimated by samples generated from Stan, red represents ABC-Hawkes. All estimates are based on the complete, undistorted data sets.}
  \label{fig_post_proofofconcept}
\end{figure}

In \citet{ertekin_reactive_2015}, a Hawkes process is defined which has an intensity function containing both an inhibiting and exciting component, as well as a constant background intensity $\lambda_0$, and $C_1$, a term to deal with zero-inflation. In their simulation study (provided in their supplementary materials) they fix both $\lambda_0$ and $C_1$ to their true values, which only leaves two free parameters, i.e. they do not consider the full estimation problem where the background intensity needs to be learned in addition to the triggering kernel. To estimate the posterior distributions using ABC \citet{ertekin_reactive_2015} use two summary statistics: the log-number of events and the KL divergence between the histograms of the interevent times $\Delta_i$ of the true and simulated data set.

For our comparison we generate three data sets from a Hawkes process. We use a constant background intensity $\mu$, which is assumed fixed and known for all methods to facilitate a direct  comparison with \citet{ertekin_reactive_2015}. Hence, we are left to estimate the posteriors of the two free parameters from the exponential excitation kernel from Equation~\eqref{eq_exponential}, hence $\theta' = (K, \beta)$. The priors for the Hawkes parameters are chosen to be relatively uninformative: $ K \sim \mathcal{U}(0, 0.9)$, $ \beta \sim \mathcal{U}(0.1, 3)$. Without any data distortion, Figure~\ref{fig_post_ert} compares the true posterior distribution to the estimates using the two summary statistics from \citet{ertekin_reactive_2015} and ABC-Hawkes. It is evident that ABC-Hawkes does a better job at capturing the posterior distributions across all parameters and data sets, showing that it is able to  estimate the Hawkes parameters despite not evaluating the likelihood function.

\begin{figure}[t]
  \flushleft
   \begin{subfigure}{.2\textwidth}
      \flushright
      Data Set 1
  \end{subfigure}
  \begin{subfigure}{.3\textwidth}
      \centering
      \includegraphics[width=.99\linewidth]{figures/ertekin/sim_data1_K.pdf}
  \end{subfigure}
  \begin{subfigure}{.3\textwidth}
      \centering
      \includegraphics[width=.99\linewidth]{figures/ertekin/sim_data1_beta.pdf}
  \end{subfigure} \\
  \begin{subfigure}{.2\textwidth}
      \flushright
      Data Set 2
  \end{subfigure}
  \begin{subfigure}{.3\textwidth}
      \centering
      \includegraphics[width=.99\linewidth]{figures/ertekin/sim_data2_K.pdf}
  \end{subfigure}
  \begin{subfigure}{.3\textwidth}
      \centering
      \includegraphics[width=.99\linewidth]{figures/ertekin/sim_data2_beta.pdf}
  \end{subfigure}\\
  \begin{subfigure}{.2\textwidth}
      \flushright
      Data Set 3
  \end{subfigure}
  \begin{subfigure}{.3\textwidth}
      \centering
      \includegraphics[width=.99\linewidth]{figures/ertekin/sim_data3_K.pdf}
      \caption{$K$}
  \end{subfigure}
  \begin{subfigure}{.3\textwidth}
      \centering
      \includegraphics[width=.99\linewidth]{figures/ertekin/sim_data3_beta.pdf}
       \caption{$\beta$}
  \end{subfigure}
  \caption{Undisturbed data posterior distributions. Each row uses a different simulated data set. Parameters $(K, \beta)$ are chosen as $(0.5, 0.5)$, $(0.3, 0.8)$, and $(0.3, 1)$ for the three data sets. The black curve shows the true posterior estimated by samples generated from Stan, red represents ABC-Hawkes, and green the approach by \citet{ertekin_reactive_2015}. All estimates are based on the complete, undistorted data sets.}
  \label{fig_post_ert}

\end{figure}

\subsection{Distortion -- Twitter Data Example} \label{sub_twitter}

We next apply the ABC-Hawkes algoorithm to parameter estimation in distorted data. For this purpose, we will manually insert distortion into a real data set and then compare the posterior distribution estimated from the distorted data, to that estimated from the original undistorted data.

For the real data, we choose to study the occurrence time of tweets on Twitter, which previous research has shown can be accurately modeled by a Hawkes process \citep{mei_neural_2017}. We use a Twitter data set that was previously analyzed by \citet{rizoiu_tutorial_2017} and describes the retweet cascade of an article published in the New York Times. While this data set is complete (and we can hence obtain the true posterior distribution), we will manually create a gap in the data to assess whether the true posterior can be recovered using only this distorted data.

To evaluate ABC-Hawkes, we use the first $150$ event times in the tweet data. To artificially create a gap, we delete all observations from observation $t_{60}$ to observation $t_{90}$, to produce the incomplete data. The be relatively uninformative priors are chosen as above: $\mu \sim \mathcal{U}(0.05, 0.85)$, $ K \sim \mathcal{U}(0, 0.9)$, $ \beta \sim \mathcal{U}(0.1, 3)$. The restriction that $K<1$ is standard, and ensures that data sampled from the Hawkes process contain a finite number of events with probability 1.

We generate samples from the true parameter posteriors using Markov Chain Monte Carlo as implemented in the Stan \citep{Stan_RStan_2019} probabilistic programming language, as applied to the complete data. This represents the idealized ``ground truth'' posterior that would be obtained if we had access to the true undistorted data. We then  apply ABC-Hawkes to the observed data only (i.e. the distorted, incomplete data), with the goal of recovering this true posterior. In the implementation of the ABC-MCMC algorithm we use independent random walk Gaussian proposal distribution for the $q(\cdot|\cdot)$ transition kernels, with  standard deviations $(0.05, 0.05, 0.2)$ for $(\mu, K, \beta)$ respectively. To assess the performance of ABC-Hawkes, we compare the obtained posterior to three alternative methods that could be used: (1) MCMC (using Stan) applied to the incomplete data, which represents the naive attempt to learn the Hawkes parameters directly using only the observed data and ignoring the missing data. (2) MCMC (using Stan) applied only to the observations $[0, T_a]$ before the start of the gap. This is ``unbiased'' since it uses a sequence of data where all tweets are available, but is inefficient due to the smaller resulting set. (3) The missing data algorithm suggested by \cite{tucker_handling_2019}, which is a specialised algorithm applicable only to data where the distortion consists of gaps. Their approach alternates between two steps. First, they impute the missing data based on the complete pre-gap data and a given parameter vector. Second, they update the parameter vector based on the imputed data set of full length, where likelihood evaluations are possible. This approach has the advantage of targetting the correct posterior, however it can suffer from slow mixing since the probability of a MCMC example being accepted is low.

We note that approaches (2) and (3) are only applicable to this specific choice of distortion function where the distortion consists of no detected events at all during the gap period, and (unlike ABC-Hawkes), are not applicable to more general types of distortion, as will be discussed in the next section.

Figure~\ref{fig_post_unmarked} shows the resulting posterior density estimates for all these methods, and Table~\ref{tab_twitter} contains the posterior means and standard deviations. It can be seen that the ABC-Hawkes algorithm does an excellent job of recovering the posterior distribution despite the missing data, and is very close to the true posterior mean for each of the model parameters. In contrast, the naive approach (which ignores the gap) produces a highly biased posterior which is not close to the true posterior means of $\mu$ and $K$. Both the approach from \cite{tucker_handling_2019} and the method which uses only the observations prior to the gap do substantially better than the naive approach, but are inferior to ABC Hawkes.

\begin{table}[t]
  \caption{Twitter data posterior mean (and standard deviation)}
  \label{tab_twitter}
  \centering
  \begin{tabular}{lccc}
\toprule
Model & $\mu$ & $K$ & $\beta$ \\
  \midrule
  \textbf{True Posterior} &  \textbf{0.55 (0.13)} &\textbf{0.65 (0.10)} & \textbf{0.91 (0.28)} \\
  \midrule
 ABC-Hawkes  &  0.59 (0.15) & 0.68 (0.11) & 1.00 (0.51) \\
 Naive & 0.22 (0.08) & 0.80 (0.07) & 0.87 (0.23) \\
Pre-gap only  & 0.68 (0.13) & 0.61 (0.13) & 1.49 (0.57) \\
\citet{tucker_handling_2019}  & 0.61 (0.14) & 0.66 (0.10) & 1.08 (0.34) \\
 \addlinespace[0.5ex]
\bottomrule
\end{tabular}
\end{table}

\begin{figure}[t]
  \centering
  \begin{subfigure}{.3\textwidth}
      \centering
      \includegraphics[width=.99\linewidth]{figures/twitter/Twitter_mu.pdf}
      \caption{$\mu$}
      \label{subfig_unmarked_mu}
  \end{subfigure}
  \begin{subfigure}{.3\textwidth}
      \centering
      \includegraphics[width=.99\linewidth]{figures/twitter/Twitter_K.pdf}
      \caption{$K$}
      \label{subfig_unmarked_K}
  \end{subfigure}
  \begin{subfigure}{.3\textwidth}
      \centering
      \includegraphics[width=.99\linewidth]{figures/twitter/Twitter_beta.pdf}
      \caption{$\beta$}
      \label{subfig_unmarked_beta}
  \end{subfigure}
  \caption{Twitter data posterior distributions. Black represents the true posterior using both observed and missing data. Red represents ABC-Hawkes using only the incomplete data. The naive approach using only the incomplete data is green, while the yellow and blue lines respectively show the approach that only uses the observations before the gap, and the  \citet{tucker_handling_2019} imputation method.}
  \label{fig_post_unmarked}

\end{figure}

\subsection{Other Distortion Settings}

The above section showed that ABC-Hawkes can accurately recover the true posterior when there are gaps in the data. However a key advantage of our approach is that \citep[unlike the approach from][]{tucker_handling_2019} it can also be used when the data is distorted in other ways. To investigate this, we use a simulation study where we generate data sets from a Hawkes process and manually distort it in various ways. The first type of distortion involves a time-varying detection rate, while the second involves noisy data. The prior distribution for $\theta$ is taken to be the same as above and we again used Stan \citep{Stan_RStan_2019} to sample from the idealized parameter posterior using the undistorted data, which acts as a baseline that would be obtained if no distortion were present.

For the first type of distortion, we use a linearly decaying detection function where an event that occurs at time $t$ is observed with probability $  h(t) = 1- (a + b \, \frac{t}{T})$ where $a = 0.35$ and $b = -0.25$, and missing otherwise. Hence, earlier events have a lower probability of being observed. Similar time-varying detection functions have been applied in the earthquake literature \citep{ogata_immediate_2006} and hence this is plausible specification. For the second type of distortion, we create a ``noisy'' version of the data set by adding Gaussian errors to each observation, i.e. replacing each $t_i$ with $t'_i = t_i + \varepsilon_i$ where $\varepsilon_i \sim \mathcal{N}(0,0.5^2)$.

For both distorted data sets, we compute the posterior using ABC-Hawkes on the observed (distorted) data using the same Metropolis-Hastings transition kernel as above, and compare it to the idealized posterior computed on the true data. Unlike in the above missing data case, we are not aware of any other published algorithms which can handle these two types of distortion, so the only other comparison we make is to the naive method which learns the posterior using the observed data without taking the distortion into account. In Figure~\ref{fig_post_sim}, the posterior density estimates are plotted, and Table~\ref{tab_simulated} shows the posterior means and standard deviations for both scenarios. Again, ABC-Hawkes manages to learn the model parameters accurately and produces a posterior distribution which is remarkably close to the true posterior. In contrast, the naive approach is severely biased and does not get close to the true posterior. Again we note that the slight overestimation of the posterior variance is an inherent issue with ABC that comes from a necessary non-zero choice of $\epsilon_p$ \citep{li_convergence_2017}.

\begin{table}[!th]
  \caption{Simulated data posterior mean (and standard deviation)}
  \label{tab_simulated}
  \centering
  \begin{tabular}{llccc}
\toprule
Distortion &  Model   &  $\mu$ & $K$ & $\beta$ \\
  \midrule
   &  \textbf{True Posterior}  & \textbf{0.51 (0.07)} & \textbf{0.15 (0.09)} & \textbf{1.45 (0.80)}  \\
Lin. Deletion &  ABC-Hawkes & 0.50 (0.08) & 0.21 (0.11) & 1.54 (0.81)  \\
& Naive  & 0.41 (0.07) & 0.19 (0.12) & 1.22 (0.79) \\
 \midrule
 &  \textbf{True Posterior}  & \textbf{0.24 (0.04)} & \textbf{0.38 (0.10)} & \textbf{0.69 (0.31)}  \\

Noise   & ABC-Hawkes  & 0.25 (0.04) & 0.32 (0.09) & 0.98 (0.48) \\
 & Naive &  0.29 (0.03) & 0.23 (0.04) & 2.89 (0.11) \\

\bottomrule
\end{tabular}
\end{table}

\begin{figure}[!th]
  \centering
  \begin{subfigure}{.3\textwidth}
      \centering
      \includegraphics[width=.99\linewidth]{figures/lin/sim_lin_mu.pdf}
      \label{subfig_sim_exp_mu}
  \end{subfigure}
  \begin{subfigure}{.3\textwidth}
      \centering
      \includegraphics[width=.99\linewidth]{figures/lin/sim_lin_K.pdf}
      \label{subfig_sim_exp_K}
  \end{subfigure}
  \begin{subfigure}{.3\textwidth}
      \centering
      \includegraphics[width=.99\linewidth]{figures/lin/sim_lin_beta.pdf}
      \label{subfig_sim_exp_beta}
  \end{subfigure}
  \begin{subfigure}{.3\textwidth}
      \centering
      \includegraphics[width=.99\linewidth]{figures/noise/sim_noise_mu.pdf}
      \caption{$\mu$}
      \label{subfig_sim_noise_mu}
  \end{subfigure}
  \begin{subfigure}{.3\textwidth}
      \centering
      \includegraphics[width=.99\linewidth]{figures/noise/sim_noise_K.pdf}
      \caption{$K$}
      \label{subfig_sim_noise_K}
  \end{subfigure}
  \begin{subfigure}{.3\textwidth}
      \centering
      \includegraphics[width=.99\linewidth]{figures/noise/sim_noise_beta.pdf}
      \caption{$\beta$}
      \label{subfig_sim_noise_beta}
  \end{subfigure}
  \caption{Distorted data posterior distributions. \textbf{Top row:} data distortion through a detection function using exponential decay. \textbf{Bottom row:} data distortion by adding noise. \textbf{Colours:}  Black represents the true posterior using the undistorted data, red represents ABC-Hawkes using the distorted data, and green represents the naive model using the distorted data. }
  \label{fig_post_sim}

\end{figure}

\section{Discussion} \label{sec_summary}

In this paper we have demonstrated that it is possible to successfully learn the parameters of a Hawkes process even when the data is distorted through mechanisms such as missingness or noise. We have based our algorithm on ABC-MCMC, which has been adapted to the unique structure of a self-exciting point process. Unlike a naive MCMC approach which ignores the potential distortion, the resulting ABC-Hawkes algorithm can learn the true posterior distribution that would have been obtained given access to the undistorted data. The strong performance of ABC-Hawkes was demonstrated using a variety of realistic data distorting mechanisms. Future research could expand the theory to other data-distorting mechanisms, for example additive noise in a multivariate setting \citep{trouleau_learning_2019} or censoring \citep{xu_learning_2017}.

While our simulation study focused on a simple Hawkes process with a parametrically specified self-excitation kernel, our approach is much more general than this and can be applied to other specifications of the Hawkes process as long as the resulting model is generative so that data sets $p(Y|\theta)$ can be simulated conditional on a parameter vector $\theta$. This includes recent specifications of the Hawkes process using nonparametric estimation \citep{chen_nonparametric_2016} or
LTSM networks \citep{mei_neural_2017}, which is a potential avenue for future research.

\bibliographystyle{apalike}


\section{Introduction}
Non-leptonic weak decays are valuable tools for testing the Standard
Model (SM), the Kobayashi-Maskawa (KM) mechanism, and the unitarity of
the Cabibbo-Kobayashi-Maskawa (CKM) matrix, and for exploring physics
beyond the SM. Among non-leptonic decays, the decay of the light
pseudoscalar meson $\eta'\to K^{\pm}\pi^{\mp}$ is interesting because
it is fundamental to understand the long-standing problem of the
$\Delta I=1/2$ rule in weak non-leptonic interactions.

The experimental $\Delta I=1/2$ rule was first established in the
decay $K\to\pi\pi$. A neutral kaon may decay into two pions with
amplitudes $A_{0}$ or $A_{2}$, respectively. As the real parts of these
amplitudes, Re$A_{0}$ is dominated by $\Delta I=1/2$ transitions and
Re$A_{2}$ receives contributions from $\Delta I=3/2$ transitions, the
former transitions dominate Re$A_{0}$, which expresses the so-called
$\Delta I=1/2$ rule~\cite{deltaIrule1,deltaIrule2}
\begin{equation}
  \begin{aligned}
    \frac{\text{Re}A_{0}}{\text{Re}A_{2}}=22.35.
  \end{aligned}
\end{equation}
Despite nearly 50 years of efforts, the microscopic dynamical
mechanism responsible for such a striking phenomenon is still elusive.
The decay $\eta'\to K^{\pm}\pi^{\mp}$ receives contributions from both
the $\Delta I=1/2$ and $\Delta I=3/2$ parts of the weak
hamiltonian~\cite{bergstrom1988weak}. It is possible to see whether
the $\Delta I=1/2$ rule is functional in this type of decay, and this
could shed light on the origin of this rule.  The branching fraction
of $\eta^{\prime}\to K^{\pm}\pi^{\mp}$ decay is predicted to be of the order
of $10^{-10}$ or higher~\cite{bergstrom1988weak}, with a large
long-range hadronic contribution expected, which should become
observable in high luminosity electron-positron collisions.

At present, there is no experimental information on the decay
$\eta^{\prime}\to K^\pm\pi^\mp$.  The world's largest sample of
$1.3\times 10^9$ $J/\psi$ events produced at rest and collected with
the BES\uppercase\expandafter{\romannumeral3}\xspace detector therefore offers a good opportunity to search for this rare
decay. In this paper, the measurement of the ratio
$\frac{{\cal B}(\eta'\to K^{\pm}\pi^{\mp})}{{\cal B}(\eta'\to
  \gamma\pi^{+}\pi^{-})}$ is presented, where the $\eta^\prime$ is
produced in the decay $J/\psi\to\phi\eta^\prime$. The advantage of
comparing these two $\eta^\prime$ decay channels is that parts of the
systematic uncertainties due to the tracking, the particle
identification (PID), the branching fractions ${\cal B}(J/\psi\to\phi\eta^{\prime})$ and ${\cal B}(\phi\to K^{+}K^{-})$,
and the number of $J/\psi$ events cancel in
the ratio. A measurement of the branching fraction $J/\psi\to\phi\eta^{\prime}$
is also presented in which $\phi$ is reconstructed in its $K^{+}K^{-}$
decay mode and $\eta^{\prime}$ is detected in the $\gamma\pi^+\pi^-$ decay
mode. This can be compared with the results reported by the
BESII~\cite{ablikim2005measurements},
MarkIII~\cite{MARKIIImeasurements}, and DM2~\cite{DM2measurements} collaborations.

\section{\texorpdfstring{Detector and Monte Carlo Simulation}{Detector and MC Simulation}}
BEPCII is a double-ring $e^{+}e^{-}$ collider designed to provide a
peak luminosity of $10^{33}$~cm$^{-2}s^{-1}$ at the center-of-mass
(c.m.) energy of 3.770 GeV.  The BES\uppercase\expandafter{\romannumeral3}\xspace~\cite{Ablikim2010345}
detector, with a geometrical acceptance of 93\% of the 4$\pi$ stereo
angle, is operating in a magnetic field of 1.0 T provided by a
superconducting solenoid magnet. It is composed of a helium-based
drift chamber (MDC), a plastic scintillator Time-Of-Flight (TOF)
system, a CsI(Tl) electromagnetic Calorimeter (EMC) and a multi-layer
resistive plate chamber (RPC) muon counter system (MUC).

Monte Carlo (MC) simulations are used to determine the mass resolutions
and detection efficiencies. The GEANT4-based simulation
software BOOST~\cite{ref:boost} includes the geometric and material
description of the BES\uppercase\expandafter{\romannumeral3}\xspace detector, the detector response, and the
digitization models, as well as the detector running conditions and
performance.  The production of the $J/\psi$ resonance is simulated with
the MC event generator KKMC~\cite{ref:kkmc,ref:kkmc2}, while the
decays are generated by EVTGEN~\cite{ref:evtgen} for known decay modes
with branching fractions set to the Particle Data Group
(PDG)~\cite{PDG2014} world average values, and by
LUNDCHARM~\cite{ref:lundcharm} for the remaining unknown decays.  The
analysis is performed in the framework of the BES\uppercase\expandafter{\romannumeral3}\xspace offline software
system (BOSS)~\cite{ref:boss}.

\section{Data analysis}
\subsection{\texorpdfstring{ $J/\psi\to\phi\eta'$, $\eta^\prime\to\gamma\pi^+\pi^-$}{eta' to gampipi}}
For the decay $J/\psi\to\phi\eta'$, $\phi\toK^{+}K^{-}$,
$\eta^\prime\to\gamma\pi^+\pi^-$, candidate events are selected
by requiring four well reconstructed charged tracks and at least one
isolated photon in the EMC.  The four charged tracks are required to
have zero net charge. Each charged track, reconstructed using hits in
the MDC, is required to be in the polar angle range
$|\cos\theta| < 0.93$ and pass within $\pm10$~cm of the interaction
point along the beam direction, and within $\pm1$~cm in the plane
perpendicular to the beam, with respect to the interaction point. For
each charged track, information from the TOF and the specific
ionization measured in the MDC ($dE/dx$) are combined to
form PID confidence levels (C.L.) for the $K$, $\pi$ and $p$
hypotheses, and the particle type with the highest C.L.\ is assigned to
each track. Two of the tracks are required to be identified as kaons and the
remaining two tracks as pions.

Photon candidates are reconstructed by clusters of energy deposited in
the EMC.  The energy deposited in the TOF counter in front of the EMC
is included to improve the reconstruction efficiency and the energy
resolution. Photon candidates are required to have a deposited
energy larger than 25 MeV in the barrel region ($|\cos\theta|<0.80$)
and 50 MeV in the end-cap region ($0.86<|\cos\theta|<0.92$). EMC
cluster timing requirements are used to suppress electronic noise and
energy deposits that are unrelated to the event. To eliminate showers
associated with charged particles, the angle between the cluster and
the nearest track must be larger than 15$^{\circ}$.
\begin{figure}[htbp]
  \includegraphics[width=0.45\textwidth]{mgampippim_vs_mkpkm_chi2Cut.eps}
  \caption{\label{PhiGamPiPi_scatter}Scatter plot of $M(\gamma\pi^{+}\pi^{-})$ versus $M(K^{+}K^{-})$ .}
\end{figure}
\begin{figure*}[htbp]
  \includegraphics[width=0.45\textwidth]{log_mkpkm_fit_2d_RBW_Cheby.eps}\put(-70,110){\bf (a)}
  \includegraphics[width=0.45\textwidth]{log_mgampippim_fit_2d_RBW_Cheby.eps}\put(-70,110){\bf (b)}
  \caption{\label{nominal_fit_result}Distributions of (a) $M(K^{+}K^{-})$ and
    (b) $M(\gamma\pi^{+}\pi^{-})$ with projections of the fit result superimposed
    for $J/\psi\to\phi\eta', \phi\toK^{+}K^{-}, \eta'\to\gamma\pi^{+}\pi^{-}$. The
    dots with errors are for data, the solid curve shows the result of
    the fit to signal plus background distributions, the long-dashed
    curve is for $\phi\eta'$ signal, the dot-dashed curve shows the
    non-$\eta'$-peaking background, the dotted curve shows the
    non-$\phi$-peaking background, and the short-dashed curve is for
    non-$\phi\eta'$ background.}
\end{figure*}

A four-constraint (4C) kinematic fit is performed to the
$\gammaK^{+}K^{-}\pi^{+}\pi^{-}$ hypothesis. For events with more than one photon
candidate, the candidate combination with the smallest $\chi^{2}_{4C}$
is selected, and it is required that $\chi^{2}_{4C}<50$.

The scatter plot of $M(\gamma\pi^+\pi^-)$ versus $M(K^{+}K^{-})$ is shown in
Fig.~\ref{PhiGamPiPi_scatter}, where the $J/\psi\to\phi\eta^\prime$
decay is clearly visible. To extract the number of $\phi\eta^\prime$ events,
an unbinned extended maximum likelihood fit is performed to the
$M(\gamma\pi^{+}\pi^{-})$ versus $M(K^{+}K^{-})$ distribution  with the
requirements of 0.988~GeV/$c^2$ $< M(K^{+}K^{-}) < 1.090$~GeV/$c^2$ and
0.880~GeV/$c^2$ $< M(\gamma\pi^{+}\pi^{-}) < 1.040$~GeV/$c^2$. Assuming zero
correlation between the two discriminating variables $M(K^{+}K^{-})$ and
$M(\gamma\pi^{+}\pi^{-})$, the composite probability density function (PDF)
in the 2-dimensional fit is constructed as follows
\begin{equation}
  \begin{aligned}
    F&=N_\text{sig}\times (F_\text{sig}^{\phi}\cdot F_\text{sig}^{\eta'})\\
    &+N_\text{bkg}^{\text{non-}\eta'}\times (F_\text{sig}^{\phi}\cdot F_\text{bkg}^{\text{non-}\eta'})\\
    &+N_\text{bkg}^{\text{non-}\phi}\times (F_\text{bkg}^{\text{non-}\phi}\cdot F_\text{sig}^{\eta'})\\
    &+N_\text{bkg}^{\text{non-}\phi\eta'}\times (F_\text{bkg}^{\text{non-}\phi}\cdot F_\text{bkg}^{\text{non-}\eta'}).
  \end{aligned}
\end{equation}
Here, the signal shape for $\phi$ (\emph{i.e.} $F_\text{sig}^{\phi}$) is modeled
with a relativistic Breit-Wigner function convoluted with a Gaussian
function taking into account the detector resolution; the signal
shape for $\eta'$ ($i.e.~F_\text{sig}^{\eta'}$) is described by a normal
Breit-Wigner function convoluted with a Gaussian function. The widths
and masses of $\phi$ and $\eta'$ are free parameters in the fit. The
background shape of $\phi$ ($F_\text{bkg}^{\text{non-}\phi}$) is described by
a second order Chebychev polynomial function, and the background shape
of $\eta'$ ($F_\text{bkg}^{\text{non-}\eta'}$) is described by a first order
Chebychev polynomial function. All parameters related to the
background shapes are free in the fit. $N_\text{sig}$ is the number of
$J/\psi\to\phi\eta', \phi\toK^{+}K^{-}, \eta'\to\gamma\pi^{+}\pi^{-}$ signal
events. The backgrounds are divided into three categories:
non-$\phi\eta'$ background ($i.e.~J/\psi\to\gammaK^{+}K^{-}\pi^{+}\pi^{-}$);
non-$\phi$-peaking background ($i.e.~J/\psi\toK^{+}K^{-}\eta'$); and
non-$\eta'$-peaking background
($i.e.~J/\psi\to\phi\gamma\pi^{+}\pi^{-}$). The parameters $N_\text{bkg}^{\text{non-}\phi\eta'}$,
$N_\text{bkg}^{\text{non-}\phi}$ and $N_\text{bkg}^{\text{non-}\eta'}$ are the
corresponding three background yields.

The resulting fitted number of signal events is
$N_\text{sig}=(31321\pm201)$; the projections of the fit on the $M(K^{+}K^{-})$
and $M(\gamma\pi^{+}\pi^{-})$ distributions are shown in
Figs.~\ref{nominal_fit_result} (a) and (b), respectively.  The
detection efficiency, $32.96\pm0.04$\%, is obtained from the MC
simulation in which the angular distribution and the shape of
$M(\pi^{+}\pi^{-})$ are taken into account according to a
previous BES\uppercase\expandafter{\romannumeral3}\xspace measurement for
$\eta'\to\pi^{+}\pi^{-}e^{+}e^{-}$~\cite{Eta'ToPiPiEE}, where the
non-resonant contribution (known as the ``box anomaly'') is included
in the simulation of $\eta^{\prime}\to\gamma\pi^{+}\pi^{-}$.

\subsection{\texorpdfstring{$J/\psi\to\phi\eta', \eta'\to K^{\pm}\pi^{\mp}$}{eta' to Kpi}}
\begin{figure*}[htbp]
  \includegraphics[width=0.45\textwidth]{mKPi_vs_mphi_enlarge_rectangle.eps}\put(-50,110){\bf (a)}
  \includegraphics[width=0.45\textwidth]{mKPi_Cut_3.eps}\put(-50,110){\bf (b)}
  \caption{\label{PhiKPi_plot}(a) Scatter plot of $M(K^{+}K^{-})$ versus
    $M(K^{\pm}\pi^{\mp})$, where the box indicates the signal region
    with $|M(K^{+}K^{-})-M(\phi)| < 15$~MeV/$c^2$ and
    $|M(K^\pm\pi^\mp)-M(\eta')| < 7$~MeV/$c^2$. (b) The $K^ \pm
    \pi^\mp$ invariant mass distribution, where the arrows show the
    signal region. The dots with error bars are for data, the dashed
    histogram is for the signal MC with arbitrary normalization, and
    the solid histogram is the background contamination from a MC
    simulation of $J/\psi \to \phi\pi^+\pi^-$.}
\end{figure*}
To search for $\eta'\to K^{\pm}\pi^{\mp}$, the two-body decay
$J/\psi\to\phi\eta'$ is chosen because of its simple event topology,
$K^+K^-K^{\pm}\pi^{\mp}$, and because the narrow $\phi$ meson is easy to
detect through $\phi\to K^+K^-$ decay.  The selection criteria for the
charged tracks are the same as that for the
$J/\psi\to\phi\eta', \eta'\to \gamma\pi^{+}\pi^{-}$ decay. Three tracks
are required to be identified as kaons with the combination of TOF and $dE/dx$
information and the remaining one is required to be identified as a pion.

A 4C kinematic fit imposing energy-momentum conservation is performed
under the $K^{+}K^{-} K^\pm\pi^\mp$ hypothesis, and a requirement of
$\chi^2_{4C}<50$ is imposed.  To suppress the dominant background
contamination from $J/\psi\to\phi\pi^{+}\pi^{-}$, the $\chi^2_{4C}$ of the
$K^{+}K^{-} K^{\pm}\pi^{\mp}$ hypothesis is required to be less than that for the
$K^{+}K^{-}\pi^{+}\pi^{-}$ hypothesis. Candidates for $\phi\to K^+K^-$  are reconstructed from the
$K^{+}K^{-}$ combination with invariant mass closest to the nominal
mass value. The remaining kaon together with the pion form the $\eta'$
candidate.

Fig.~\ref{PhiKPi_plot} (a) shows the scatter plot to the invariant
mass $M(K^{+}K^{-})$ versus $M(K^\pm\pi^{\mp})$. The process $\phi\eta^{\prime} (\eta'\to K^{\pm}\pi^{\mp})$ would result in an enhancement of events around the nominal masses of
the $\phi$ and $\eta'$ mesons, while no evident cluster is
seen. Within three standard deviations of the $\phi$ mass,
$|M(K^{+}K^{-})-M(\phi)| < 15$ MeV/$c^2$, the $K^{\pm}\pi^{\mp}$ invariant
mass distribution is displayed in Fig.~\ref{PhiKPi_plot} (b); a
few events are retained around the $\eta^\prime$ mass region, shown as
the dots with error bars. To estimate the number of signal events
passing the selection criteria, a region of $\pm3\sigma$ around the
$\eta^{\prime}$ nominal mass is selected, that is
$|M(K^\pm\pi^\mp)-M(\eta')| < 7$~MeV/$c^2$, where $\sigma =2.2$~MeV
is the mass resolution determined from MC simulation. Only one event
survives in the signal region for further analysis.

To investigate the potential background contributions, a study with an inclusive MC
sample of $1.2\times 10^9$ generic $J/\psi$ decays is performed. It is found
that the remaining background events mainly come from
$J/\psi\to\phi\pi^+\pi^-$.  Therefore an exclusive MC sample of
$1.3\times 10^6$ $J/\psi\to\phi\pi^+\pi^-$ events is generated in
accordance with the partial wave analysis results of
Ref.~\cite{PhiPiPifromBESII}.
This sample corresponds to twice the
expected $J/\psi\to\phi\pi^{+}\pi^{-}$ events in data.  After normalizing to the
world average value for ${\cal B}(J/\psi\to\phi\pi^{+}\pi^{-})$, 2.0 events are expected
in the $K\pi$ mass range of [0.88, 1.04] GeV/$c^2$, with a total of 0.5
events in $\eta'$ signal region, as shown by the solid histogram in Fig.~\ref{PhiKPi_plot} (b).

To conservatively estimate the upper limit, it is assumed that the
only event in the signal region is a signal event. According to the Feldman-Cousins
method~\cite{UpperLimit}, the corresponding upper limit of the number
of events is $N^\text{UL} = 4.36$ at the 90\% C.L.

\section{Systematic Uncertainties}

The systematic uncertainties in branching fraction measurement
originate mainly from the differences of data and MC on tracking efficiency, photon reconstruction, PID
efficiency, and the 4C kinematic fit, different fitting
range and background shape,
uncertainties from ${\cal B}(\phi\toK^{+}K^{-}$) and ${\cal B}(\eta'\to\gamma\pi^{+}\pi^{-})$, total number
of $J/\psi$ events and MC statistics. Other uncertainties related to the
common selection criteria of the channels
$J/\psi\to\phi\eta^{\prime}, \eta'\to K^{\pm}\pi^{\mp}$ and
$J/\psi\to\phi\eta^{\prime}, \eta^{\prime}\to\gamma\pi^{+}\pi^{-}$ cancel to first order in the
ratio between the branching fractions.

The systematic uncertainties associated with the tracking efficiency
and PID efficiency have been studied in the analysis of
$J/\psi\to p\bar{p}\pi^{+}\pi^{-}$ and
$J/\psi\to K_{S}^{0}K^{\pm}\pi^{\mp}$~\cite{trackingeff, PIDeff}. The
results indicate that the kaon/pion tracking and PID efficiencies for
data agree with those of MC simulation within 1\%.

The photon detection is estimated by the study of
$J/\psi\to\rho\pi$~\cite{trackingeff}. The difference in the detection
efficiency between data and MC is less than 1\% per photon, which is
taken as the systematic uncertainty because of the only photon in the
$J/\psi\to\phi\eta^{\prime}, \eta^{\prime}\to\gamma\pi^{+}\pi^{-}$ channel.

The uncertainty associated with the 4C kinematic fit comes from the
difference between data and MC simulation. The method used in this
analysis is to correct the tracking parameters of the helix fit to
reduce the difference between MC and data, as described in
Ref.~\cite{refsmear}. This procedure yields a systematic uncertainty
of 0.3\% and 1.0\% for the measurement of ${\cal B}(J/\psi\to\phi\eta')$ and
the search of $\eta'\to K^{\pm}\pi^{\mp}$, respectively.

To estimate the systematic contribution due to the fit ranges,
several alternative fits in different ranges are performed. The
maximum difference on the number of signal events from alternative
fits in different mass ranges is 0.1\%, and this value is taken as
systematic uncertainty.  To estimate the systematic contribution due
to the background shape, a fit is performed replacing the 2nd-order
Chebychev polynomial function with an Argus function~\cite{ref:Argus};
the change of signal yields is found to be 0.04\%, which is negligible.

The decay $J/\psi\to\phi\eta', \phi\toK^{+}K^{-}, \eta'\to\gamma\pi^{+}\pi^{-}$
is used as control sample to estimate the uncertainty from the $\phi$ mass
window criterion in the search of $\eta'\to K^{\pm}\pi^{\mp}$. The
$\phi$ mass window criterion is applied to the control sample, and a
fit is performed to $M(\gamma\pi^{+}\pi^{-})$. After considering the efficiency difference,
the difference of 1.2\% in the number of
signal events between this fit and the nominal 2D fit is taken as the
uncertainty from the $\phi$ mass window.

The uncertainties on the intermediate-decay branching fractions of
$\phi\toK^{+}K^{-}$ and $\eta'\to\gamma\pi^{+}\pi^{-}$ are taken from world
average values~\cite{PDG2014}.

The above systematic uncertainties together with the uncertainties due
to the number of $J/\psi$ events~\cite{JpsiNumberof2009, JpsiNumberofLiHuijuan} and MC
statistics are all summarized in Table~\ref{summary_of_syserr}, where
the uncertainties associated with MDC tracking, PID, branching
fraction of $\phi\toK^{+}K^{-}$ cancel in the ratio
$\frac{\mathcal{B}(\eta^\prime \to K^\pm \pi^\mp) }
{\mathcal{B}(\eta^\prime \to\gamma\pi^+\pi^-) }$. The total systematic
uncertainty is taken to be the sum in quadrature of the individual
contributions.
\begin {table*}[htp]
  {\caption {Summary of systematic uncertainty sources and their contributions (in \%).}
    \label{summary_of_syserr}}
  \begin{tabular}{c|c|c}  \hline \hline
    Source & ${\cal B}(J/\psi\to\phi\eta')$ & ${\cal B}(\eta'\to K^{\pm}\pi^{\mp})$/${\cal B}(\eta'\to\gamma\pi^{+}\pi^{-})$\\ \hline
    Tracking efficiency & 4.0 & - \\ \hline
    PID efficiency & 4.0 & - \\ \hline
    Photon reconstruction & 1.0 & 1.0 \\ \hline
    4C kinematic fit & 0.3 & 1.0 \\ \hline
    Fit range & 0.1 & 0.1 \\ \hline
    Background shape & - & - \\ \hline
    $\phi$ mass window & - & 1.2 \\ \hline
    ${\cal B}(\phi\toK^{+}K^{-})$ & 1.0 & - \\ \hline
    ${\cal B}(\eta'\to\gamma\pi^{+}\pi^{-})$ & 2.0 & - \\ \hline
    $N_{J/\psi}$ & 0.8 & - \\ \hline
    MC statistic of $\eta'\to\gamma\pi^{+}\pi^{-}$ & 0.1 & 0.1 \\ \hline
    MC statistic of $\eta'\to K^{\pm}\pi^{\mp}$ & - & 0.1 \\ \hline
    Total & 6.2 & 1.9 \\ \hline \hline
  \end{tabular}
\end{table*}

\section{Results}
At the 90\% C.L., the upper limit on the ratio of
${\cal B}(\eta'\to K^{\pm}\pi^{\mp})$ to
${\cal B}(\eta'\to\gamma\pi^{+}\pi^{-})$ is given by
\begin{equation}
  \begin{aligned}
    \frac{\mathcal{B}(\eta'\to
      K^{\pm}\pi^{\mp})}{\mathcal{B}(\eta'\to\gamma\pi^{+}\pi^{-})}<\frac{
      N^\text{UL}\cdot\varepsilon_{\gamma\pi^+\pi^-} } {
      N_\text{sig}\cdot\varepsilon_{ K^\pm\pi^\mp}}\frac{1}
    {(1-\sigma_\text{syst})},
  \end{aligned}
\end{equation}
where $N^\text{UL}$ is the upper limit of the number of observed
events at the 90\% C.L. for $\eta^\prime\to K^\pm\pi^\mp$;
$\varepsilon_{ K^\pm\pi^\mp}$ and $\varepsilon_{\gamma\pi^+\pi^-}$ are
the detection efficiencies of $J/\psi\to\phi\eta^{\prime}$ for the two decays
which are obtained from the MC simulations; $\sigma_\text{syst}$ is the
total systematic uncertainty in the search of
$\eta'\to K^{\pm}\pi^{\mp}$.  The 90\% C.L. upper limit on the ratio
$\frac{{\cal B}(\eta'\to
  K^{\pm}\pi^{\mp})}{{\cal B}(\eta'\to\gamma\pi^{+}\pi^{-})}$ is determined
to be $1.3\times10^{-4}$ by using the values of different parameters
listed in Table~\ref{numbers_of_calculation}.
\begin {table}[htp]
  {\caption {Values used in the calculations of the branching
      ratios, including the fitted signal yields,  $N$ (or 90\%
      C.L. upper limit) and the detection efficiency, $\varepsilon$.}
    \label{numbers_of_calculation}}
  \begin {tabular}
    {cc c} \hline \hline
    Decay mode & $\varepsilon$ (\%) & $N$ \\
    \hline
    $\eta'\to K^{\pm}\pi^{\mp}$ & 36.75$\pm$0.04 & $<$4.36 (90\% C.L.)\\
    $\eta'\to\gamma\pi^{+}\pi^{-}$ & 32.96$\pm$0.04 & 31321$\pm$201 \\
    \hline \hline
  \end{tabular}
\end{table}

The branching fraction of $J/\psi\to\phi\eta'$ decay is calculated with the equation
\begin{equation}
  \begin{aligned}
    &{\cal B}(J/\psi\to\phi\eta')\\
    &=\frac{N_\text{sig} /\varepsilon_{\gamma \pi^+\pi^-}}{ N_{J/\psi}{\cal B}(\eta'\to\gamma\pi^{+}\pi^{-}){\cal B}(\phi\toK^{+}K^{-})},
  \end{aligned}
\end{equation}
where $N_{J/\psi} = 1310.6\times10^{6}$ is the number of $J/\psi$ events
as determined by $J/\psi$ inclusive hadronic
decays~\cite{JpsiNumberof2009, JpsiNumberofLiHuijuan}.  The obtained value for the
branching fraction of $J/\psi\to\phi\eta'$ is
$(5.10\pm0.03(\text{stat.})\pm0.32(\text{syst.}))\times 10^{-4}$.

\section{Summary}
Based on the $1.3 \times 10^{9}$ $J/\psi$ events accumulated with the
BESIII detector, a search for the non-leptonic weak decay
$\eta'\to K^{\pm}\pi^{\mp}$ is performed for the first time through
the $J/\psi\to\phi\eta'$ decay. No evidence for
$\eta^{\prime}\to K^{\pm}\pi^{\mp}$ is seen, and the 90\% C.L. upper limit on
the ratio of
$\frac{{\cal B}(\eta'\to
  K^{\pm}\pi^{\mp})}{{\cal B}(\eta'\to\gamma\pi^{+}\pi^{-})}$ is measured
to be $1.3\times10^{-4}$. Using the world average value of
$\mathcal{B}(\eta^{\prime}\to\gamma\pi^+\pi^-)$~\cite{PDG2014}, the
corresponding upper limit on
$\mathcal{B}(\eta^\prime\to K^\pm\pi^\mp)$ is calculated to be
$3.8\times10^{-5}$.

For the determination of the ratio of
$\frac{{\cal B}(\eta'\to
  K^{\pm}\pi^{\mp})}{{\cal B}(\eta'\to\gamma\pi^{+}\pi^{-})}$, the
$J/\psi\to\phi\eta'$ decay with
$\phi\toK^{+}K^{-}, \eta'\to\gamma\pi^{+}\pi^{-}$ is analyzed and the
corresponding branching fraction is
${\cal B}(J/\psi\to\phi\eta')=(5.10\pm0.03(\text{stat.})\pm0.32(\text{syst.}))\times10^{-4}$. It
is the most precise measurement to date and in agreement with the world average value.

\begin{acknowledgments}
The BESIII collaboration thanks the staff of BEPCII and the IHEP computing center for their strong support. This work is supported in part by National Key Basic Research Program of China under Contract No. 2015CB856700; National Natural Science Foundation of China (NSFC) under Contracts Nos. 11125525, 11235011, 11322544, 11335008, 11425524, 11105101, 11205117, 11575133, 11175189; the Chinese Academy of Sciences (CAS) Large-Scale Scientific Facility Program; the CAS Center for Excellence in Particle Physics (CCEPP); the Collaborative Innovation Center for Particles and Interactions (CICPI); Joint Large-Scale Scientific Facility Funds of the NSFC and CAS under Contracts Nos. 11179007, U1232201, U1332201, U1232109; CAS under Contracts Nos. KJCX2-YW-N29, KJCX2-YW-N45; 100 Talents Program of CAS; National 1000 Talents Program of China; INPAC and Shanghai Key Laboratory for Particle Physics and Cosmology; German Research Foundation DFG under Contract No. Collaborative Research Center CRC-1044; Istituto Nazionale di Fisica Nucleare, Italy; Ministry of Development of Turkey under Contract No. DPT2006K-120470; Russian Foundation for Basic Research under Contract No. 14-07-91152; The Swedish Research Council; U. S. Department of Energy under Contracts Nos. DE-FG02-04ER41291, DE-FG02-05ER41374, DE-FG02-94ER40823, DESC0010118; U.S. National Science Foundation; University of Groningen (RuG) and the Helmholtzzentrum fuer Schwerionenforschung GmbH (GSI), Darmstadt; WCU Program of National Research Foundation of Korea under Contract No. R32-2008-000-10155-0.
\end{acknowledgments}