Trimmed Density Ratio Estimation

Density ratio estimation is a vital tool in both machine learning and statistical community. However, due to the unbounded nature of density ratio, the estimation procedure can be vulnerable to corrupted data points, which often pushes the estimated ratio toward infinity. In this paper, we present a robust estimator which automatically identifies and trims outliers. The proposed estimator has a convex formulation, and the global optimum can be obtained via subgradient descent. We analyze the parameter estimation error of this estimator under high-dimensional settings. Experiments are conducted to verify the effectiveness of the estimator.


Introduction
estimator. However, it is not clear how to de-bias such an estimator to recover the true density ratio function. [26] took a more direct approach. It estimates a thresholded density ratio by setting up a tolerance t to the density ratio value. All likelihood ratio values bigger than t will be clipped to t. The estimator was derived from Fenchel duality for f -divergence [18]. However, the optimization for the estimator is not convex if one uses log-linear models. The formulation also relies on the non-parametric approximation of the density ratio function (or the log ratio function) making the learned model hard to interpret. Moreover, there is no intuitive way to directly control the proportion of ratios that are thresholded. Nonetheless, the concept studied in our paper is inspired by this pioneering work.
In this paper, we propose a novel method based on a "trimmed Maximum Likelihood Estimator" [17,10]. This idea relies on a specific type of density ratio estimator (called log-linear KLIEP) [30] which can be written as a maximum likelihood formulation. We simply "ignore" samples that make the empirical likelihood take exceedingly large values. The trimmed density ratio estimator can be formulated as a convex optimization and translated into a weighted M-estimator. This helps us develop a simple subgradient-based algorithm that is guaranteed to reach the global optimum.
Moreover, we shall prove that in addition to recovering the correct density ratio under the outlier setting, the estimator can also obtain a "corrected" density ratio function under a truncation setting. It ignores "pathological" samples and recovers density ratio only using "healthy" samples.
Although trimming will usually result a more robust estimate of the density ratio function, we also point out that it should not be abused. For example, in the tasks of two-sample test, a diverging density ratio might indicate interesting structural differences between two distributions.
In Section 2, we explain some preliminaries on trimmed maximum likelihood estimator. In Section 3, we introduce a trimmed DRE. We solve it using a convex formulation whose optimization procedure is explained in Section 4. In Section 5, we prove the estimation error upper-bound with respect to a sparsity inducing regularizer. Finally, experimental results are shown in Section 6 and we conclude our work in Section 7.

Preliminary: Trimmed Maximum Likelihood Estimation
Although our main purpose is to estimate the density ratio, we first introduce the basic concept of trimmed estimator using density functions as examples. Given n samples drawn from a distribution P , i.e., X := x (i) n i=1 i.i.d.
∼ P, x ∈ R d , we want to estimate the density function p(x). Suppose the true density function is a member of exponential family [20], where f (x) is the sufficient statistics, Z(θ) is the normalization function and q(x) is the base measure.
Maximum Likelihood Estimator (MLE) maximizes the empirical likelihood over the entire dataset. In contrast, a trimmed MLE only maximizes the likelihood over a subset of samples according to their likelihood values (see e.g., [10,31]). This paradigm can be used to derive a popular outlier detection method, one-class Support Vector Machine (one-SVM) [24]. The derivation is crucial to the development of our trimmed density ratio estimator in later sections.
Without loss of generality, we can set the log likelihood function as log p(x (i) ; θ) − τ 0 , where τ 0 is a constant. As samples corresponding to high likelihood values are likely to be inliers, we can trim all samples whose likelihood is bigger than τ 0 using a clipping function This optimization has a convex formulation: where is the slack variable measuring the difference between log p x (i) ; θ and τ 0 . However, formulation (2) is not practical since computing the normalization term Z(θ) in (1) is intractable for a general f and it is unclear how to set the trimming level τ 0 . Therefore we ignore the normalization term and introduce other control terms: The 2 regularization term is introduced to avoid θ reaching unbounded values. A new hyper parameter ν ∈ (0, 1] replaces τ 0 to control the number of trimmed samples. It can be proven using KKT conditions that at most 1 − ν fraction of samples are discarded (see e.g., [24], Proposition 1 for details). Now we have reached the standard formulation of one-SVM. This trimmed estimator ignores the large likelihood values and creates a focus only on the low density region. Such a trimming strategy allows us to discover "novel" points or outliers which are usually far away from the high density area.

Trimmed Density Ratio Estimation
In this paper, our main focus is to derive a robust density ratio estimator following a similar trimming strategy. First, we briefly review the a density ratio estimator [27] from the perspective of Kullback-Leibler divergence minimization.

Density Ratio Estimation (DRE)
For two sets of data X p := {x ∼ Q, assume both the densities p(x) and q(x) are in exponential family (1). We know p(x;θp) q(x;θq) ∝ exp [ θ p − θ q , f (x) ] . Observing that the data x only interacts with the parameter θ p − θ q through f , we can keep using f (x) as our sufficient statistic for the density ratio model, and merge two parameters θ p and θ q into one single parameter δ = θ p − θ q . Now we can model our density ratio as where N (δ) is the normalization term that guarantees q(x)r(x; δ)dx = 1 so that q(x)r(x; δ) is a valid density function and is normalized over its domain. Interestingly, despite the parameterization (changing from θ to δ), (4) is exactly the same as (1) where q(x) appeared as a base measure. The difference is, here, q(x) is a density function from which X q are drawn so that N (δ) can be approximated accurately from samples of Q. Let us definê Note this model can be computed for any f even if the integral in N (δ) does not have a closed form .
In order to estimate δ, we minimize the Kullback-Leibler divergence between p and q · r δ : where c is a constant irrelevant to δ. It can be seen that the minimization of KL divergence boils down to maximizing log likelihood ratio over dataset X p . Now we have reached the log-linear Kullback-Leibler Importance Estimation Procedure (log-linear KLIEP) estimator [30,14].

Trimmed Maximum Likelihood Ratio
As stated in Section 1, to rule out the influences of large density ratio, we trim samples with large likelihood ratio values from (6). Similarly to one-SVM in (2), we can consider a trimmed MLEδ = arg max δ where t 0 is a threshold above which the likelihood ratios are ignored. It has a convex formulation: (7) is similar to (2) since we have only replaced p(x; θ) withr(x; δ). However, the ratio modelr(x; δ) in (7) comes with a tractable normalization termN while the normalization term Z in p(x; θ) is in general intractable. Similar to (3), we can directly control the trimming quantile via a hyper-parameter ν: where R(δ) is a convex regularizer. (8) is also convex, but it has n p number of non-linear constraints and the search for the global optimal solution can be time-consuming. To avoid such a problem, one could derive and solve the dual problem of (8). In some applications, we rely on the primal parameter structure (such as sparsity) for model interpretation, and feature engineering. In Section 4, we translate (8) into an equivalent form so that its solution is obtained via a subgradient ascent method which is guaranteed to converge to the global optimum.
One common way to construct a convex robust estimator is using a Huber loss [12]. Although the proposed trimming technique rises from a different setting, it shares the same guiding principle with Huber loss: avoid assigning dominating values to outlier likelihoods in the objective function.
In Section 8.1 in the supplementary material, we show the relationship between trimmed DRE and binary Support Vector Machines [23,4].

Optimization
The key to solving (8) efficiently is reformulating it into an equivalent max min problem. Proposition 1. Assuming ν is chosen such thatt > 0 for all optimal solutions in (8), then δ is an optimal solution of (8) if and only if it is also the optimal solution of the following max min problem: The proof is in Section 8.2 in the supplementary material. We define (δ,ŵ) as a saddle point of (9): where the second ∇ δ means the subgradient if R is sub-differentiable. Now the "trimming" process of our estimator can be clearly seen from (9): The max procedure estimates a density ratio given the currently assigned weights w, and the min procedure trims the large log likelihood ratio values by assigning corresponding w i to 0 (or values smaller than 1 np ). For simplicity, we only consider the cases where ν is a multiple of 1 np . Intuitively, 1 − ν is the proportion of likelihood ratios that are trimmed thus ν should not be greater than 1. Note if we set ν = 1, (9) is equivalent to the standard density ratio Algorithm 1 Gradient Ascent and Trimming Input: X p , X q , ν and step sizes {η it } itmax it=1 ; Initialize δ 0 , w 0 , Iteration counter: it = 0, Maximum number of iterations: it max , Best objective, parameter pair (O best = −∞, δ best , w best ) . while not converged and it ≤ it max do Obtain a sorted set x ) and update (δ best , w best ) accordingly. it = it + 1. end while Output: (δ best , w best ) estimator (6). Downweighting outliers while estimating the model parameter δ is commonly used by robust estimators (See e.g., [3,29]).
The search for (δ,ŵ) is straightforward. It is easy to solve with respect to w or δ while the other is fixed: given a parameter δ, the optimization with respect to w is a linear programming and one of the extreme optimal solutions is attained by assigning weight 1 np to the elements that correspond to the νn p -smallest log-likelihood ratio logr(x (i) , δ). This observation leads to a simple "gradient ascent and trimming" algorithm (see Algorithm 1). In Algorithm 1, In fact, Algorithm 1 is a subgradient method [2,16], since the optimal value function of the inner problem of (9) is not differentiable at some δ where the inner problem has multiple optimal solutions. The subdifferential of the optimal value of the inner problem with respect to δ can be a set but Algorithm 1 only computes a subgradient obtained using the extreme point solution w it+1 of the inner linear programming. Under mild conditions, this subgradient ascent approach will converge to optimal results with diminishing step size rule and it → ∞. See [2] for details. Algorithm 1 is a simple gradient ascent procedure and can be implemented by deep learning softwares such as Tensorflow 1 which benefits from the GPU acceleration. In contrast, the original problem (8), due to its heavily constrained nature, cannot be easily programmed using such a framework.

Estimation Consistency in High-dimensional Settings
In this section, we show how the estimated parameterδ in (10) converges to the "optimal parameters" δ * as both sample size and dimensionality goes to infinity under the "outlier" and "truncation" setting respectively.
In the outlier setting (Figure 1a), we assume X p is contaminated by outliers and all "inlier" samples in X p are i.i.d.. The outliers are injected into our dataset X p after looking at our inliers. For example, hackers can spy on our data and inject fake samples so that our estimator exaggerates the degree of change.
In the truncation setting, there are no outliers. X p and X q are i.i.d. samples from P and Q respectively. However, we have a subset of "volatile" samples in X p (the rightmost mode on histogram in Figure 1b) that are pathological and exhibit large density ratio values.
In the theoretical results in this section, we focus on analyzing the performance of our estimator for high-dimensional data assuming the number of non-zero elements in the optimal δ * is k and use the 1 regularizer, i.e., R(θ) = θ 1 which induces sparsity onδ. The proofs rely on a recent development [35,34] where a "weighted" high-dimensional estimator was studied. We also assume the optimization of δ in (9) was conducted within an 1 ball of width ρ, i.e., Ball(ρ), and ρ is wisely chosen so that the optimal parameter δ * ∈ Ball(ρ). The same technique was used in previous works [15,35].
Notations: We denote w * ∈ R np as the "optimal" weights depending on δ * and our data. To lighten the notation, we shorten the log density ratio model as The proof of Theorem 1, 2 and 3 can be found in Section 8.4, 8.5 and 8.6 in supplementary materials.

A Base Theorem
Now we provide a base theorem giving an upperbound of δ − δ * . We state this theorem only with respect to an arbitrary pair (δ * , w * ) and the pair is set properly later in Section 5.2 and 5.3.
We make a few regularity conditions on samples from Q. Samples of X q should be well behaved in terms of log-likelihood ratio values.
We also assume the Restricted Strong Convexity (RSC) condition on the covariance of X q , i.e., cov( . Note this property has been verified for various different design matrices X q , such as Gaussian or sub-Gaussian (See, e.g., [21,22]).
Theorem 1. In addition to Assumption 1 and 2, there exists coherence between parameter w and δ at a saddle point (δ,ŵ): whereû :=δ − δ * , κ 2 > 0 is a constant and τ 2 (d, n) > 0. It can be shown that if and with probability converging to one.
The condition (11) states that if we swapŵ for w * , the change of the gradient ∇ δ L is limited. Intuitively, it shows that our estimator (9) is not "picky" on w: even if we cannot have the optimal weight assignment w * , we can still use "the next best thing",ŵ to compute the gradient which is close enough. We later show how (11) is satisfied. Note if ∇ δ L(δ * , w * ) ∞ , τ 2 (n, d) converge to zero as n p , n q , d → ∞, by taking λ n as such, Theorem 1 guarantees the consistency ofδ. In Section 5.2 and 5.3, we explore two different settings of (δ * , w * ) that make ||δ − δ * converges to zero.

Consistency under Outlier Setting
Setting: Suppose dataset X p is the union of two disjoint sets G (Good points) and B (Bad points) such that G Figure 1a).
∼ q(x) does not contain any outlier. We set ν = |G| np . The optimal parameter δ * is set such that p(x) = q(x)r(x; δ * ). We set w * i = 1 np , ∀x (i) p ∈G and 0 otherwise.
Remark: Knowing the inlier proportion |G|/n p is a strong assumption. However it is only imposed for theoretical analysis. As we show in Section 6, our method works well even if ν is only a rough guess (like 90%). Loosening this assumption will be an important future work.
This assumption says that the log density ratio model is Lipschitz continuous around its optimal parameter δ * and hence there is a limit how much a log ratio model can deviate from the optimal model under a small perturbation u. As our estimated weightsŵ i depends on the relative ranking ofẑδ(x (i) p ), this assumption implies that the relative ranking between two points will remain unchanged under a small perturbation u if they are far apart. The following theorem shows that if we have enough clearance between "good"and "bad samples", δ converges to the optimal parameter δ * .
Theorem 2. In addition to Assumption 1, 2 and a few mild technical conditions (see Section 8.5 in the supplementary material), Assumptions 3 holds. Suppose min j∈B z δ * (x kλ n with probability converging to 1. It can be seen that δ − δ * = O log d/min(|G|, n q ) if d is reasonably large.

Consistency under Truncation Setting
In this setting, we do not assume there are outliers in the observed data. Instead, we examine the ability of our estimator recovering the density ratio up to a certain quantile of our data. This ability is especially useful when the behavior of the tail quantile is more volatile and makes the standard estimator (6) output unpredictable results.
∼ Q. Truncated densities p δ and q δ are the unbounded densities p and q restricted only on the truncated domain X(δ). Note that the truncated densities are dependent on the parameter δ and ν. We show that under some assumptions, the parameterδ obtained from (9) using a fixed hyperparameter ν will converge to the δ * such that q δ * (x)r(x; δ * ) = p δ * (x). We also define the "optimal" weight assignment p ∈ X(δ * ) and 0 otherwise. Interestingly, the constraint in (9), w * , 1 = ν may not hold, but our analysis in this section suggests we can always find a pair (δ,ŵ) in the feasible region so that δ − δ * converges to 0 under mild conditions. We first assume the log density ratio model and its CDF is Lipschitz continuous.

Assumption 4.
∀u ∈ Ball(ρ), sup Define In this assumption, we define a "zone" T (u, ) near the ν-th quantile t(δ * ) and assume the CDF of our ratio model is upper-bounded over this region. Different from Assumption 3, the RHS of (12) is with respect to 2 norm of u. In the following assumption, we assume regularity on P and Q.
Theorem 3. In addition Assumption 1 and 2 and other mild assumptions (see Section 8.6 in the supplementary material), Assumption 4 and 5 hold.
It can be seen that δ − δ * = O log d/min(|X p (δ * )|, n q ) if d is reasonably large and |X q \X q (δ * )|/n q decays fast.
6 Experiments 6.1 Detecting Sparse Structural Changes between Two Markov Networks (MNs) [14] In the first experiment 2 , we learn changes between two Gaussian MNs under the outlier setting. The ratio between two Gaussian MNs can be parametrized as is the difference between precision matrices. We generate 500 samples as X p and X q using two randomly structured Gaussian MNs. One point [10, . . . , 10] is added as an outlier to X p . To induce sparsity, we set R(∆) = d i,j=1,i≤j |∆ i,j | and fix λ = 0.0938. Then run DRE and TRimmed-DRE to learn the sparse differential precision matrix ∆ and results are plotted on Figure 2a    the ground truth (the position i, j, ∆ * i,j = 0) is marked by red boxes. It can be seen that the outlier completely misleads DRE while TR-DRE performs reasonably well. We also run experiments with two different settings (d = 25, d = 36) and plot True Negative Rate (TNR) -True Positive Rate (TPR) curves. We fix ν in TR-DRE to 90% and compare the performance of DRE and TR-DRE using DRE without any outliers as gold standard (see Figure 2c). It can be seen that the added outlier makes the DRE fail completely while TR-DRE can almost reach the gold standard. It also shows the price we pay: TR-DRE does lose some power for discarding samples. However, the loss of performance is still acceptable.

Relative Novelty Detection from Images
In the second experiment, we collect four images (see Figure 3a) containing three objects with a textured background: a pencil, an earphone and an earphone case. We create data points from these four images using sliding windows of 48 × 48 pixels (the green box on the lower right picture on Figure 3a). We extract 899 features using MATLAB HOG method on each window and construct an 899-dimensional sample. Although our theorems in Section 5 are proved for linear models, here f (x) is an RBF kernel using all samples in X p as kernel basis. We pick the top left image as X p and using all three other images as X q , then run TR-DRE, THresholded-DRE [26], and one-SVM.
In this task, we select high density ratio super pixels on image X p . It can be expected that the super pixels containing the pencil will exhibit high density ratio values as they did not appear in the reference dataset X q while super pixels containing the earphone case, the earphones and the background, repeats similar patches in X q will have lower density ratio values. This is different from a conventional novelty detection, as a density ratio function help us capture only the relative novelty. For TR-DRE, we use the trimming thresholdt as the threshold for selecting high density ratio points.
It can be seen on Figure 3b, 3c and 3d, as we tune ν to allow more and more high density ratio windows to be selected, more relative novelties are detected: First the pen, then the case, and finally the earphones, as the lack of appearance in the reference dataset X q elevates the density ratio value by different degrees. In comparison, we run TH-DRE with top 3% highest density ratio values thresholded, which corresponds to ν = 97% in our method. The pattern of the thresholded windows (shaded in red) in Figure 3e is similar to Figure 3b though some parts of the case are mistakenly shaded. Finally, one-SVM with 3% support vectors (see Figure 3f) does not utilize the knowledge of a reference dataset X q and labels all salient objects in X p as they corresponds to the "outliers" in X p .

Conclusion
We presents a robust density ratio estimator based on the idea of trimmed MLE. It has a convex formulation and the optimization can be easily conducted using a subgradient ascent method. We also investigate its theoretical property through an equivalent weighted M-estimator whose 2 estimation error bound was provable under two high-dimensional, robust settings. Experiments confirm the effectiveness and robustness of the our trimmed estimator.

Appendix
To lighten the notation system, we drop the feature transform f from our equations. The analysis procedure does not change with or without f .

Relationship between Trimmed DRE and Binary SVM [23, 4]
Consider a "symmetrized" extension to the criterion (6): that jointly minimizes the KL divergence from P to Q and from Q to P . Similar to (5), we user 2 to model the ratio q/p: The minus in front of the δ is due to the inversion of the ratio. We can trim the objective function (13) and add a regularization term λR(δ) as we did for the asymmetric one: Proposition 2. If n p = n q , t 0 = 1, R(·) = · 2 2 , the maximizerδ of (14) is the same as the primal solution of a modified SVM using X p and X q as positive and negative class respectively.
It suggests SVM learns an unnormalized and trimmed density ratio function as the decision function.
Proof. By introducing the slack variables as we did in (7). (14) can be rewritten as: After substitutingr andr 2 , (15) can be rewritten as Let n p = n q , t 0 = 1, R(δ) = δ 2 , (16) is an SVM (without a bias term) using X p and X q as positive and negative samples respectively, except the presences of log normalization terms logN (δ) and logN 2 (δ).

Proof of Proposition 1
Proof. To prove the statement, we construct the dual of (8) which has the exactly same form as (9). Denote ∈ R d×nq . The Lagrangian of (8) can be written as where α ∈ R np + , α ∈ R + , α ∈ R + . Now we analyze the KKT condition of the above Lagrangian.
Suppose the optimalt > 0 4 , then α = 0 by the slackness condition that t α = 0. The optimality condition of t in (17) yields: and the optimality condition of yields From (18) and (19), and the slackness condition of optimization (7), we can see x (i) p ∈ X p , if logr(x (i) p ; δ) < t, then i > 0 which leads to α i = 0 (the constraint of i ≥ 0 is ineffective) and thus α i = 1 np . In contrast, if logr(x (i) p ; δ) > t, then we have α i = 0, i = 0 (the constraint of i ≥ 0 is effective). If logr(x (i) p ; δ) falls right on the boundary t, i.e., log r(x (i) p ; δ) = t, α i ∈ [0, 1 np ], since the KKT condition i α i = 0 indicating α i can take non-negative values as long as 1 np · 1 = α + α . We summarize: It can be observed that for (8), (δ = 0, = 0.2 · 1, t = 0.1) is a feasible interior point, and it makes all inequality constraints strict, so the Slater's condition holds for our original primal problem which is also convex. Therefore, the lagrangian dual of the original problem (8) is which is the same as (9) and any points satisfy the KKT condition are both dual (22) and primal (8) optimal.
8.3 Lemma 1 Lemma 1. If Assumptions 1 and 2 hold, then where c is the constant determined by Assumption 2.
Proof. First, we write down -∇ 2 δ L(δ * + u, w * ): , then we have the following inequalities We then invoke Assumption 2 to obtain ν

Proof of Theorem 1
Proof. First, we define the S and S c are the set of indices of non-zero and zero elements of δ * . The cardinlity of S is k. Defineû :=δ − δ * . From the Lemma 1 we can see that, where we set κ 1 := Using Holder's inequality, The introduction of ρ is due to the bounded optimization region. Due to (11), we can convert the above inequality into and because of the setting of λ n , Note that in the first term,δ is obtained at the stationary condition, which implies that there is a subgradient, denoted by ∇ δ 1 , such that (the second ∇ is the subgradient notation) thus we can obtain the upper-bound of ∇ δ L(δ,ŵ),û using the following standard procedure: 1 ) due to convexity of δ 1 and the definition of subgradient.

Proof of Theorem 3
First we verify (11).

Lemma 3. Under Assumptions 4 and 5,
where L is a positive constant. The second term reflects the cost of using the empirical sample to control the ν-th quantile in (28). It can be seen that κ 2 = 2 √ kC CDF C p , τ 2 (n, d) = 2L·Cp √ np . The proof of Lemma 3 uses a fact that only x p in the "zone" T (u, L 1 √ np ) are "dangerous" as they may be mistakenly included or missed out under small perturbation of u. See Section 8.8 in Appendix for the proof.
The reason for this arrangement can be seen from Figure 4. Denote e (j) := exp δ * , x (j) q , s := nq j=1 e (j) ands = i∈G e (i) . Note that Now, as X p (δ * ) and G contains only i.i.d. samples and due to the definition of δ * , we can invoke Lemma 2 again from [14] to bound a(n, d). That is if Assumptions 6 and 7 hold and n q = Ω(n 2 p ), and λ n ≥ where K 1 and c 1 are constants. By taking the extra 2C 2 r |B|Cq nq into account, we obtain Lemma 4.

Proof of Lemma 3
Before we start, we need to define a few empirical counterparts of population quantities used in Section 5.3.
• P n is the empirical distribution of P .

Numerical Analysis
In this section, we present a few numerical experimental results under outlier and truncation setting. In all experiments, we set n p = n q = 5000, λ = 0, and the solution ofδ was obtained using Algorithm 1. We let f (x) = x. Note this is the correct log-ratio model for two Gaussian distributions with different means.
Outlier Setting In this setting, we first generate two "good" datasets G i.i.d.
∼ q(x) = N (−.75, 1). The outlier set B b is generated from a uniform distribution U (−0.4 + b, 0.4 + b), b ∈ [0, 6]. The density ratio estimation is performed using two sets of data: X p,b = {G, B b } and X q , where the cardinality of B is 1000. We repeat the estimation using different choices of b and test its influence on our estimater(x;δ b ). The results can be seen from Figure 6, where the histograms of G and X q are colored red and green respectively. The true density ratio p(x) q(x) is plotted as a dotted line. The histograms of B b with different choices of b was plotted using gradient colors from light blue to purple (we skipped some choices of b for better visualization). For each b, we run the density ratio estimation, and plot learnedr(x;δ b ) using the same gradient color. In the figure, we resaler(x;δ b ) and the true density ratio using a same constant, so they can be plotted alongside with the histogram. Here, we test two methods: the log-Linear KLIEP and the robust estimator proposed in this paper.
It can be easily seen that as b → 6, KLIEP (Figure 6a) tends to significantly overestimate the density ratio and is sensitive to the change of b. The proposed method (Figure 6b), tends to underestimate the density ratio when b is small. However, as b gradually shifts away from the center of X p , leaving the "gap" between inlier and outlier, the robust estimator converges to the true density ratio function.
Truncated Setting In this setting, we generate samples X p i.i.d.
∼ p(x) = N (0, 1) without any contamination. Usually, the ν-th quantile of z(x p ; δ * ) cannot be analytically computed as we do not know the true density ratio. However, it can be seen that for a strictly monotone increasing z(x p , δ * ), samples in the ν-th quantile of z(x p , δ * ) must be in the ν-th quantile of x p since the relative order among x p is preserved after a strictly monotone transform. Thus, we obtain the truncation domain X(δ * ) = {−∞ ≤ x ≤ Φ −1 (ν)}, where Φ −1 is the inverse CDF of N (0, 1). We then generate samples X q ∼ T N (−0.5, 1, −∞, Φ −1 (ν)), where T N is a truncated Gaussian distribution and the last two parameters are the truncation borders. Note we set the mean of Q to be a negative value so that the true density ratiop/q is a monotone increasing function.
The results for ν = 0.5 are plotted on Figure 7 where the true truncated ratio is plotted as a dotted line. It can be seen that the learnedr(x;δ) is fairly close to the true truncated density ratio.