\section{Introduction}
\label{sec:intro}

AM CVn binaries are a kind of interacting binary systems consisting of accreting white dwarfs (WDs) and He-rich donor stars. They are important for studies of binary evolution \citep[e.g.][]{py14,tv23}, binary population synthesis \citep[e.g.][]{npvy01,hgcc20} and common envelope evolution \citep[e.g.][]{ijcd+13,kndg+21}. Given the short periods ($\sim 5 - 66\;$min) of AM CVn binaries, they are important gravitational wave (GW) sources for  space-borne low-frequency GW observatories like LISA \citep{aabb+17}, TianQin \citep{lcdg+16}, and Taiji \citep{rgcz20}. It was also suggested that AM CVn binaries can be the progenitors of type Ia supernovae \citep[][]{bswn07}.

It is known that there are three possible formation channels for AM CVn binaries. In the first channel, a WD accretes material from a semidegenerate He star \citep[e.g.][]{ty79,nrs81,it91,yung08}; In the second channel, a He WD in a double WD system transfers material to the WD accretor \citep[e.g.][]{nrs81,ty96,npvy01,ctch22a}. In this channel, the accretor is usually a CO WD. In the third channel, an evolved main sequence donor star starts mass transfer around the end of main sequence. After the donor star loses its H-rich envelope, it becomes He-rich and has a remaining mass smaller than $0.10\;M_{\odot}$, transferring material to the WD \citep[e.g.][]{phr03,ljc21}. In this paper, we mainly focus on the double WD channel.

Regarding the evolution of AM CVn binaries in the double WD channel, it has been widely investigated. Some studies \citep[e.g.][]{npvy01,mns04,gpf07,kblk17} adopted a semi-analytic method to model the evolution of AM CVn binaries. In these studies, the detailed structure of the He WD was not taken into account and the He WD was assumed to be fully degenerate. This should not be realistic since the He WDs may have small but thick envelopes. \citet{kbs12} have shown that this will have an important impact on the evolution of WD binaries and stability of mass transfer. In addition, some studies \citep[e.g.][]{dtwc07,wb21} have modelled the evolution of AM CVn stars with the He WD structure considered. They found that the initial entropy of the He WD has an impact on the evolution of AM CVn binaries. But it is worth noting that it is widely assumed that the mass transfer in AM CVn binaries is conservative and the evolution of accreted material on the CO WD is not considered in these studies.

From previous studies of He-accreting WDs, we know that the evolution of He-accreting WDs strongly depends on the WD mass and accretion rate \citep[e.g.][]{nomo82b,it89,lt91,pty14,wph17,wwlh17}.
It is shown that there is a stable burning regime in which the accreted He material can burn stably on the surface of WDs. There is little mass loss in this regime. If the accretion rate is smaller than the minimum stable burning rate, the He-burning is unstable, leading to nova outburst. A fraction of material can be lost during the nova outburst. If the accretion rate is larger than the maximum stable burning rate. The evolution is still under debate. \citet{py14} and \citet{wph17} found that the accreting WDs will evolve into red giants after a small amount of material is accreted. In this case, the binary system is likely to enter common envelope and merge eventually. On the other hand, \citet{hknu99} found that the optically thick wind \citep{kh94} will occur in this regime. In this scenario, the material on the surface of WDs burns at a rate of the maximum stable burning rate and the excess material is lost in a form of optically thick wind. With these results in mind, we can find that the mass transfer of AM CVn binaries is not likely to be conservative.

This work aims at a comprehensive study of the evolution of AM CVn binaries from double WD channel and the properties of this kind of binaries, in particular, as gravitational wave sources.

The rest of the paper is organized as follows. In section~\ref{sec:met}, we describe how we make the initial WD models and briefly outline the assumptions underlying the binary evolution. In Section~\ref{sec:res}, we present the results we obtained. In Section~\ref{sec:dis}, we first discuss the detectability of AM CVn binaries with LISA, TianQin and the properties of AM CVn binaries as GW sources. Then we also discuss the stability of mass transfer of AM CVn binaries from our simulation. In addition, we discuss the uncertainties in our simulation and their influence on our results. Finally, we summarize our conclusion in Section~\ref{sec:con}.

\section{Method and assumptions}
\label{sec:met}

\subsection{Initial He WD models}
\label{sec:ini_wd}

In this work, we adopted the He WD models from our previous work about the evolution of NS+He binaries \citep{ctch22b}. Here we briefly describe how these He WD models are made.

First, the evolution of a grid of low-mass X-ray binaries was computed with the stellar evolution code \textsc{mesa} \citep{pbdh+11,pcab+13,pmsb+15,psbb+18,pssg+19}. The initial NS and donors are assumed to be a point mass and zero-age main-sequence stars, respectively. Their masses are assumed to be $1.30\;$ and $1.20\;M_{\odot}$, respectively.
The initial orbital periods range from $1.0$ to $600\;$days. In this grid, some donors can evolve into He WDs. Then we extract the WD models when the central temperatures of He WDs are around $10^{7}\;$K.  In these models, the He WDs have H envelopes with masses smaller than $0.01\;M_{\odot}$.
The initial He WD masses are $0.17$, $0.21$, $0.25$, $0.30$, $0.35$, $0.40$, $0.45\;M_{\odot}$. Compared with the He WD models in \citet{lcch19} who modeled the formation of CO+He WDs, our He WD models may have different temperatures and H envelope masses. But from the following discussion, we can find these factors does not influence our results significantly.

\subsection{Binary evolutionary models}

To model the evolution of AM CVn binaries, we make use of the \textsf{star\_plus\_point\_mass} test suite of \textsc{mesa} code (version 12115). In our simulation, the WD accretor is assumed to be a point mass. The initial masses of WD accretors are assumed to be $0.50$, $0.60$, $0.70$, $0.80$, $0.90$, $1.00$, $1.10$, $1.20$, $1.30\;M_{\odot}$. These WDs with masses larger than $1.10\;M_{\odot}$ are ONe WDs and others are CO WDs.
The initial orbital periods are assumed to be $0.05\;$days.

In our calculation, we consider two kinds of mechanisms of angular momentum loss: GW radiation and angular momentum loss due to mass loss. The angular momentum loss due to GW radiation can be computed with the following formula \citep{ll71}:
\begin{equation}
	\frac{{\rm d}J_{\rm gw}}{{\rm d}t} = -\frac{32}{5}\frac{G^{7/2}}{c^{5}}\frac{M^2_{\rm a}M^2_{\rm d} (M_{\rm a}+M_{\rm d})^{1/2}}{a^{7/2}}\;,
\end{equation}
where $G$ is the gravitational constant and $c$ is the speed of light in vacuum; $a$ is the binary separation; $M_{\rm a}$ and $M_{\rm d}$ are the masses of the WD accretor and the WD donor, respectively.

We compute the mass transfer rate with the \textsf{Ritter} scheme \citep{ritt88}. The mass transfer in our calculation is not conservative and the isotropic re-emission model are adopted \citep{tv06}. The mass retention efficiency is computed as follows.

Given the H shell of the He WD, the accreted material is H-rich at the early phase of mass transfer. We simply assume that the retention efficiency is $0$ in this phase. We have tested that this assumption has little impact on our results. As for He burning, we adopt the optical thick wind model \citep{kh94,hkn99} and the prescription of \citet{kh04}. If the mass transfer rate ($\dot{M}_{\rm tr}$) is larger than a threshold value $\dot{M}_{\rm up}$, we assume that He burns steadily at a rate of $\dot{M}_{\rm up}$ and the excess material is lost in the form of optically thick wind. The threshold mass transfer rate is
\begin{equation}
\dot{M}_{\mathrm{up}}=7.2 \times 10^{-6}\left(M_{\mathrm{a}} / \mathrm{M}_{\odot}-0.6\right)\;\mathrm{M}_{\odot}\;\mathrm{yr}^{-1},
\label{eq:up}
\end{equation}
for accretor masses $M_{\rm a} \ge 0.75\;M_{\odot}$ \citep{nomo82b}.

If the mass transfer rate is larger than the minimum rate of stable burning ($\dot{M}_{\rm cr}$) and smaller than $\dot{M}_{\rm up}$, we assume that He burns stably on the surface of the WD and there is no mass loss. If the mass transfer rate is smaller than $\dot{M}_{\rm cr}$ but larger than $\dot{M}_{\rm low}$, we assume that the He burns unstably, triggering He flashes. In this regime, the retention efficiency is computed following \citet{kh04}. If the mass transfer rate is smaller than $\dot{M}_{\rm low}$, we assume that the He flashes is too strong to retain any material.  Therefore the retention efficiency for He burning is

$$
\eta_{\mathrm{He}}=\left\{\begin{array}{ll}
\dot{M}_{\mathrm{up}} / \dot{M}_{\mathrm{tr}} & \dot{M}_{\mathrm{tr}}\ge \dot{M}_{\mathrm{up}} \\
1 & \dot{M}_{\mathrm{up}}>\dot{M}_{\mathrm{tr}} \ge \dot{M}_{\mathrm{cr}} \\
\eta_{\mathrm{KH04}} & \dot{M}_{\mathrm{cr}}>\dot{M}_{\mathrm{tr}} \ge \dot{M}_{\mathrm{low}} \\
0 & \dot{M}_{\mathrm{tr}}<\dot{M}_{\mathrm{low}}
\end{array}\right.
$$
where
$$
\begin{array}{l}
\dot{M}_{\mathrm{cr}}=10^{-5.8}\; M_{\odot}\; \mathrm{yr}^{-1} \\
\dot{M}_{\mathrm{low}}=10^{-7.4}\; M_{\odot}\; \mathrm{yr}^{-1}.
\end{array}
$$

For WDs with masses $M_{\rm a} < 0.75\;M_{\odot}$, Eq.~\ref{eq:up} is not validated any more and we simply assume that the mass transfer is completely non-conservative, i.e. no mass is retained by the accretor. These material not accreted by the accretor leaves the system and takes away the specific angular momentum of the accretor.

In addition, we also take the Eddington limit into consideration. The Eddington limit can be given by \citep{tv23}
\begin{equation}
\dot{M}_{\rm Edd} = 4.4 \times 10^{-6}\;(M_{\rm a}/M_{\odot})\;M_{\odot}\;{\rm yr}^{-1}.
\label{eq:edd}
\end{equation}
Compared with the Eddington limit of \citet{hw99}, the Eddington limit in our calculation is lower. This can be understood as follows.
In the calculation of Eddington limit, \citet{hw99} only considered the gravitational energy released by the accreted material. However, \citet{tv23} suggest that the nuclear burning energy from these accreted material should be also considered, which leads to a lower Eddington accretion rate.
Following \citet{hw99}, we assume that the binary will merge in a common envelope if the mass transfer rate is larger than the Eddington limit. But we do not stop the calculation in order to know if the binary system can have dynamically stable mass transfer.

The inlist files for our simulations can be made available on request by contacting the corresponding author.

\section{Results}
\label{sec:res}

\subsection{Examples of binary evolution}

\begin{figure}
    \centering
    \includegraphics[width=\columnwidth]{./figures/lgt_lgmdot_sg_ex.pdf}
    \includegraphics[width=1.1\columnwidth]{./figures/lgt_ma_md_sg_ex.pdf}
    \includegraphics[width=\columnwidth]{./figures/lgt_pd_sg_ex.pdf}
    \caption{Evolution of mass transfer rate (upper panel), WD masses (middle panel) and orbital period (lower panel) as a function of time. The initial binary parameters in this example are $M_{\rm a} = 0.90\;M_{\odot}$, $M_{\rm d} = 0.21\;M_{\odot}$ and $P_{\rm orb} = 0.05\;$days. In the upper panel, the three dashed lines from up to bottom indicate $\dot{M}_{\rm up}$, $\dot{M}_{\rm cr}$ and $\dot{M}_{\rm low}$, respectively. In the middle panel, the red and blue lines are for the donor and accretor masses, respectively.    }
    \label{fig:sg_evl_ex}
\end{figure}

In Fig.~\ref{fig:sg_evl_ex}, we present an example of binary evolution of AM CVn binaries. The initial masses of the accretor and donor are $0.90\;M_{\odot}$ and $0.21\;M_{\odot}$, respectively. The initial orbital period is $0.05\;$days. From this plot, we can find that the mass transfer rate in this example is always below the stable burning regime of He (indicated by the green and red dashed lines in the upper panel). The mass of WD accretor increases when the mass transfer rate is between $\dot{M}_{\rm low}$ (see the purple dashed line) and $\dot{M}_{\rm cr}$ (see the red dashed line). At the early phase of evolution, the orbital period decreases because of GW radiation. When the H envelope is stripped, the mass transfer rate is around its maximum value and the orbital period reaches its minimum. Afterwards, the mass transfer leads to the increase of orbital period.

\begin{figure}
    \centering
    \includegraphics[width=\columnwidth]{./figures/pd_lgmdot_diff_acc.pdf}
    \includegraphics[width=\columnwidth]{./figures/lgt_pd_diff_acc.pdf}
    \includegraphics[width=\columnwidth]{./figures/lgt_ma_diff_acc.pdf}
    \caption{Evolution of mass transfer rate (upper panel), orbital period (middle panel) and accretor mass (bottom panel) for AM CV binaries with different accretor masses. In the upper panel, the arrows indicate the evolutionary direction. In these binaries, the initial donor masses and the initial orbital periods are the same, i.e. $0.21\;M_{\odot}$ and $0.05\;$days, respectively. }
    \label{fig:md_pd_lgmdot_diff_acc}
\end{figure}

\begin{figure}
    \centering
    \includegraphics[width=\columnwidth]{./figures/pd_lgmdot_diff_don.pdf}
    \includegraphics[width=\columnwidth]{./figures/md_lgmdot_diff_don.pdf}
    \caption{Evolution of mass transfer as a function of orbital period (upper panel) and He WD mass (lower panel). In the plot, the arrows indicate the evolutionary direction of binaries.
    In these binaries, the initial masses of WD accretors and the initial orbital periods are the same, i.e. $1.30\;M_{\odot}$ and $0.05\;$days, respectively. In these plot, we do not show these evolutionary tracks for these binaries with donor masses $M_{\rm d} \ge 0.30\;M_{\odot}$. This is because their mass transfer rates during their evolution can exceed the Eddington limit and we assume these binaries will merge. }
    \label{fig:md_pd_lgmdot_diff_md}
\end{figure}

In Fig.~\ref{fig:md_pd_lgmdot_diff_acc}, we show the evolution of mass transfer rate, orbital period and accretor mass for binaries with different WD accretor masses and a same donor mass.  From the upper and middle panels, we can find the evolution of mass transfer rate and orbital period are very similar for these binaries. The minimum orbital periods during the evolution are almost the same for these binaries. This is because the evolution of orbital period during the mass transfer mainly depends on the donor mass \citep{ctch22b}. In the binary system with an accretor mass of $1.30\;M_{\odot}$, the accretor mass reaches $1.40\;M_{\odot}$ during its evolution.  The WD accretor can collapse into a NS and we do not stop the calculation at that point. We have a further discussion on this kind of systems in Sec.~\ref{sec:aic}. For the systems with initial accretor masses of $0.50$ and $0.70\;M_{\odot}$, the accretor masses do not change during their evolution. This is because we assume that the mass transfer is completely non-conservative for these systems with accretor masses $M_{\rm a} \le 0.75\;M_{\odot}$.

Fig.~\ref{fig:md_pd_lgmdot_diff_md} presents the evolution of mass transfer rate as a function of orbital period and He WD masses for binaries with different He WD masses and a same accretor mass. From this plot, we can also find that these tracks converge to a single branch after the peaks of mass transfer rate.
Compared with these systems with smaller He WD masses,  the systems with massive He WDs have larger maximum mass transfer rate and smaller minimum orbital period. This is mainly because massive He WDs have smaller radius.

\section{Discussion}
\label{sec:dis}

\subsection{Properties as GW sources}
\label{sec:dis_gw}

\begin{figure*}
    \centering
    \includegraphics[width=\columnwidth]{./figures/lgt_fgw.pdf}
    \includegraphics[width=\columnwidth]{./figures/lgt_Mch.pdf}
    \includegraphics[width=\columnwidth]{./figures/lgt_snr.pdf}
    \includegraphics[width=\columnwidth]{./figures/lgf_md_sig.pdf}
    \caption{Evolution of GW frequency (panel a), chirp mass (panel b) and signal-to-noise ratio (panel c) as a function of time. Panel (d) shows the evolution of donor mass as a function of GW frequency.
    In this example, the initial binary parameters are $M_{\rm a} = 0.90\;M_{\odot}$, $M_{\rm d} = 0.21\;M_{\odot}$ and $P_{\rm orb} = 0.05\;$days. In the panel (c), the blue and red lines are computed with the sensitivity curves of LISA with an observing time of $T = 4\;$yr and TianQin with an observing time of $T = 5\;$yr, respectively. The solid and dashed lines are for AM CVn binaries at a distance of $1\;$ and $15\;$kpc, respectively. The dotted line indicates the critical SNR $= 7$, above which the source becomes detectable. In the panel (b) and (d), the magenta dashed and grey solid colors indicate the ranges in which the source is detectable by LISA at a distance of $1\;$kpc and 15\;kpc, respectively. The star symbol indicates the onset of mass transfer (${\rm log}(\dot{M}/(M_{\odot}/{\rm yr})) >= -12.0$). }
    \label{fig:gw_sg}
\end{figure*}

\begin{figure}
    \centering
    \includegraphics[width=\columnwidth]{./figures/lgf_md.pdf}
    \caption{Evolution of donor mass as a function of GW frequency for all binary systems of which mass transfer rates do not exceed the Eddington mass transfer rate. In this plot, these binaries with a same donor mass have very similar evolutionary tracks. Therefore, it appears there are only three tracks in the plot. The dotted and dashed line indicate the analytic relations from \citet{ctch22b} (see their eqs. 7 and 13) .   }
    \label{fig:md_lgf}
\end{figure}

Given the short orbital periods of AM CVn binaries, they are expected to be important sources of low GW frequency. In Fig.~\ref{fig:gw_sg}, we present an example of the evolution of GW frequency, chirp mass and signal-to-noise ratio (SNR) as a function of time for a binary system. In addition, the evolution of donor mass as a function of GW frequency is also shown.
Here the SNR for LISA and TianQin is computed with the Python package \textsc{LEGWORK} \citep{wbd22}.
The initial binary parameters are $M_{\rm a} = 0.90\;M_{\odot}$, $M_{\rm d} = 0.21\;M_{\odot}$ and $P_{\rm orb} = 0.05\;$days.
From these plots, we can find that the AM CVn binaries have a strong GW emission in the mHZ regime. The SNR can be up to $\sim 800$ ($\sim 50$) if the source is loacted at 1\;kpc (15\;kpc). If we adopt the critical SNR $= 7$, above which the source becomes detectable, then we can find that this source can be detected by LISA and TianQin. The chirp mass for the detectable source is between $0.11\;M_{\odot}$ and $0.36\;M_{\odot}$ ($0.19\;M_{\odot}$ and $0.36\;M_{\odot}$) if the source is located at a distance of $1\;$kpc (15\;kpc). The donor mass for the detectable source is between $0.03\;M_{\odot}$ and $0.21\;M_{\odot}$ ($0.07\;M_{\odot}$ and $0.21\;M_{\odot}$) if the source is located at a distance of $1\;$kpc (15\;kpc). From panel (d), we can find there is a tight relation between the donor mass and GW frequency after the maximum frequency.

In Fig.~\ref{fig:md_lgf}, we present the evolution of WD donor mass as a function of GW freqency for all binaries. In the plot, we do not show these binaries with donor masses larger than $0.30\;M_{\odot}$. This is because the mass transfer rates of these systems exceed the Eddington limit and these systems are assumed to merge in our calculation. These systems with a same donor mass have almost the same evolutionary track in this plot. Therefore, it appears that there are only three lines in the plot. From this plot, we can find that all evolutionary tracks converge to the same branch after the maximum peak in frequencies are reached. In other words, there is a linear relation between the donor mass and GW frequency. This relation has been analytically derived by \citet{ctch22b} and can be described with their eqs. 7 and 13. A fitting formula for this relation has been proposed by \citet{bkbl+18} (see their fig. 1). With this relation, we can infer the He WD mass if the GW frequency is measured. Then the accretor mass can also be derived if the chirp mass is observed.

\subsection{Stability of mass transfer}
\label{sec:dis_mt}

\begin{figure}
    \centering
    \includegraphics[width=\columnwidth]{./figures/mt_sta.pdf}
    \caption{Stability limits for mass transfer in double WD binaries. The blue and green solid lines show the dynamical stability limits from \citet{npvy01} (see their eq. 4) and \citet{mns04} (see their eq. 30). The purple dotted and red dashed lines show the threshold of Eddington limit from \citet {hw99} and \citet{npvy01}, respectively. Binaries above these lines have mass transfer rates exceed the Eddington limit in their calculations.  The open circles show all the binaries we computed and all these binaries have dynamically stable mass transfer. The crosses indicate these binaries with maximum mass transfer rates smaller than the Eddington limit in our calculation. And these squares indicate these binaries with maximum mass transfer rates below the maximum stable burning rate of He.
    }
    \label{fig:mt_sta}
\end{figure}

The stability of mass transfer of double WDs is still under debate. This problem could strongly influence the number of AM CVn and GW sources predicted by binary population synthesis model.

In Fig.~\ref{fig:mt_sta}, we present the stability limits for mass transfer of AM CVn binaries and compare our results with previous works.
Following \citet{ch08}, if a binary system has a runaway mass transfer, we assume that the binary system will have dynamically unstable mass transfer. With this criteria, we can find that all binaries in our calculation have dynamically stable mass transfer. In addition, following \citet{mns04} and \citet{kblk17}, if we adopt a critical mass transfer rate of $\dot{M} = 0.01\;M_{\odot}/{\rm yr}$ as the limit for dynamically stable mass transfer, we can also find that all binaries in our calculation have dynamically stable mass transfer.
This is very different from \citet{npvy01} and \citet{mns04} (see the solid lines in Fig.~\ref{fig:mt_sta}). The mass transfer of these binaries with smaller accretor and larger donor masses are dynamically stable in our calculation and unstable in \citet{npvy01} and \citet{mns04}.
This is partially due to that we have non-conservative mass transfer in our calculation, while they assumed conservative mass transfer in their calculation (see sec.~\ref{sec:inf_eff} for detail discussion).
In addition, a zero temperature is assumed for the WD donors in \citet{npvy01} and \citet{mns04}, which may lead to higher mass transfer rate (see sec.~\ref{sec:dis_pt} for more discussion).

\citet{hw99} suggested that a common envelope may form if the mass transfer rate in double WD binaries is larger than the Eddington limit. With this restriction, we can find the threshold for Eddington-limited mass transfer and show these binaries below the threshold with crosses in Fig.~\ref{fig:mt_sta}.
From the plot, we can find that the threshold in our calculation is slightly below that found by \citet{hw99} and \citet{nypv01}.  This is because the Eddington limit we adopted is lower than that in \citet{hw99} and \citet{nypv01}.

In our calculation, we assume that the optically thick wind occurs if the mass transfer rate is larger than the maximum stable burning rate of He. But there is another possibility in this regime. For example, \citet{pty14} found that the accreting WD may evolve into a red giant. In this scenario, the binary may enter common envelope and merge eventually. With this scenario in mind, we can find all binaries with maximum mass transfer rates smaller than the maximum stable burning rates of He \footnote{Since Eq.~\ref{eq:up} is only validated for WDs with masses $M_{\rm a} \ge 0.75\;M_{\odot}$, we adopt the maximum stable burning rate of He from \citet{pty14} for WDs with masses smaller than $0.75\;M_{\odot}$.}, which are shown as empty squares in Fig.~\ref{fig:mt_sta}. This may provide a new criterion for double WDs surviving mass transfer, which is slightly below the threshold for Eddington-limit.

\citet{cmsg+13} calculated the AM CVn space density to be $(5\pm 3) \times 10^{-7}\;{\rm pc}^{-3}$, which is 50 times smaller than the predicted value by the optimistic population synthesis model from the \citet{npvy01}.
Recently, \citet{vkgw+22} found a space density of $6^{+6}_{-2} \times 10^{-7}\;{\rm pc}^{-3}$ and confirmed this discrepancy.
Our new stability limits may have an important implication for the formation of AM CVn binaries in binary population synthesis study.
Since the stability limits in our calculation are lower than that in \citet{npvy01}, we expect that less binaries will have stable mass transfer and less AM CVn binaries will be produced in the population synthesis models. This will be helpful to mitigate this discrepancy between the theoretical model and observation.

It is also worth noting that we do not consider the rotation of the accretors in our calculation. During the mass transfer, the accretor may be spun up due to accretion. The coupling between the accretor's spin and orbit may lead to extra orbital angular momentum loss during binary evolution. \citet{mns04} showed that the coupling may have an important effect on the stability of mass transfer depending on the synchronization timescale. On the other hand, \citet{ksgm+16} have shown that the accretor velocities of two AM CVn systems, GP Com and V396 Hya, are much slower than the critical.

\subsection{Accretion induced collapse of ONe WDs}
\label{sec:aic}

As we show in Fig.~\ref{fig:md_pd_lgmdot_diff_acc}, some ONe WDs in our calculation can increase their masses to the Chandrasekhar mass limit ($\sim 1.40\;M_{\odot}$) and will collapse into NSs. At this point, the He WD masses are around $0.09 - 0.15\;M_{\odot}$. After the WD collapses into a NS, the binary system will become eccentric because of the mass loss during collapse and the natal kick of NS \citep[e.g.][]{tsyl13}.
Because of mass loss during the collapse, the Roche lobe radius of the donors increase. Then these systems may evolve into detached binaries consisting of NSs and extreme low mass He WDs. Due to the GW radiation, the He WDs in these systems may fill their Roche lobe again at some point. Then these binaries will evolve into ultra-compact X-ray binaries.

\subsection{Influence of accretion efficiency }
\label{sec:inf_eff}

\begin{figure}
    \centering
    \includegraphics[width=\columnwidth]{./figures/md_lgmdot_diff_eff.pdf}
    \caption{Comparison of the evolution of mass transfer rate between models with two different prescriptions of accretion efficiency. The blue solid (green dashed) line is for the model assuming conservative (completely non-conservative) mass transfer. The initial binary parameters in this example are $M_{\rm a} = 0.50\;M_{\odot}$, $M_{\rm d} = 0.25\;M_{\odot}$ and $P_{\rm orb} = 0.05\;$days. }
    \label{fig:com_diff_eff}
\end{figure}

In order to understand the influence of accretion efficiency, we compute the evolution of a binary system assuming the mass transfer is conservative, i.e. all the material lost by the donor is accreted by the accretor.
In Fig.~\ref{fig:com_diff_eff}, we show the comparison of the evolution of mass transfer rate for binaries with different prescriptions of retention efficiency. From this plot, we can find that their evolution is very similar. But the mass transfer rate is relatively higher in the model assuming conservative mass transfer. Binaries with high mass transfer rates are more likely to be dynamically unstable. This may partially explain the difference of dynamical stability of mass transfer between our calculation and previous studies.

\subsection{Influence of initial effective temperature and orbital period}
\label{sec:dis_pt}

\begin{figure}
    \centering
    \includegraphics[width=\columnwidth]{./figures/md_lgmdot_diff_porb.pdf}
    \caption{Evolution of mass transfer rate as a function of donor mass for binaries with different orbital periods. In these binaries, the initial WD masses are the same, i.e. $M_{\rm a} = 0.80\;M_{\odot}$ and $M_{\rm d} = 0.25\;M_{\odot}$. The initial orbital periods are $0.02$, $0.10$, $0.16$ and $0.20\;$days.}
    \label{fig:com_diff_porb}
\end{figure}

In our calculation, the initial temperatures of He WDs and orbital periods are assumed to be the same for all binaries. This may be not realistic, given that the double WD systems can be produced from stable mass transfer and common envelope ejection channels \citep{lcch19}. The He WDs in these binaries with long (short) orbital periods have long (short) time to cool down, leading to low (high) temperatures at the onset of mass transfer. Therefore, the influence of initial effective temperature and orbital period should be similar.

In order to understand their influence, we make a new $0.25\;M_{\odot}$ He WD model with a high temperature following the method described in Sec.~\ref{sec:ini_wd}. The central and effective temperatures in this model are $T_{\rm c} = 3.24 \times 10^{7}\;$K and $T_{\rm eff} = 2.74\;\times 10^{4}\;$K, respectively. With this model, we compare the evolution of mass transfer rate for binaries with different initial orbital periods, which is shown in Fig.~\ref{fig:com_diff_porb}. From this plot, we can find that the mass transfer rate is slightly higher for binaries with larger orbital periods at early phase of mass transfer. At later times, the difference is very small.

\section{Conclusions}
\label{sec:con}

In this work, we have comprehensively studied the evolution of AM CVn binaries with WD donors using the stellar evolution code \textsc{mesa}.  Instead of simply assuming conservative mass transfer, we have considered the dependence of retention efficiency on accretor mass and accretion rate. In our calculation, the accretor mass ranges from $0.50$ to $1.30\;M_{\odot}$ and the donor mass ranges from $0.17$ to $0.45\;M_{\odot}$. The main results are as follows:

\begin{itemize}
    \item These binaries with same He WD masses but different accretor masses  have very similar evolution and similar minimum orbital periods. These binaries with same accretor masses but larger donor masses have larger maximum mass transfer rate and smaller minimum orbital periods.

    \item We demonstrate that the GW signal from AM CVn binaires can be deteced by LISA and TianQin. Moreover, there is a linear relation between the WD donor mass and GW frequency during the mass transfer phase.

    \item In our calculation, all binaries have dynamically stable mass transfer, which is very different from previous studies. The threshold donor mass for Eddington-limited mass transfer for a given accretor mass is lower than previous studies. Assuming that the binary may enter common envelope if the mass transfer rate is larger than the maximum stable burning rate of He, we provide a new criterion for double WDs surviving mass transfer, which is slightly below the threshold of Eddington limit (see Fig.~\ref{fig:mt_sta}).

    \item These binaries with ONe WD accretors may evolve into binaries consisting of NS and extremely low mass WDs and further ultra-compact X-ray binaries.

\end{itemize}

\begin{acknowledgments}
HLC thanks Matthias Kruckow for useful comments.
This work is partially supported by the National Key R\&D Program of China (grant Nos. 2021YFA1600403, 2021YFA1600401), the National Natural Science Foundation of China (Grant No. 12090040/12090043, 12073071, 11873016, 11733008),
Yunnan Fundamental Research Projects (Grant No. 202001AT070058, 202101AW070003), the science research grants from the China Manned Space Project with No. CMS-CSST-2021-A10. The authors gratefully acknowledge the ''PHOENIX Supercomputing Platform'' jointly operated by the Binary Population Synthesis Group and the Stellar Astrophysics Group at Yunnan Observatories, CAS.
We are grateful to the \textsc{mesa} council for the \textsc{mesa} instrument papers and website.
\end{acknowledgments}

\vspace{5mm}
\software{MESA \citep{pbdh+11,pcab+13,pmsb+15,psbb+18,pssg+19}, LEGWORK \citep{wbd22}, matplotlib \citep{hunt07}, numpy \citep{numpy20}, astropy \citep{astropy13,astropy18},
Python from \dataset[python.org]{https://www.python.org/}}.


\section{Introduction}

\label{sec:intro}

Photometric stereo~\cite{woodham1980ps,silver1980determining} recovers detailed surface shape from image observations under varying illuminations. While many of the photometric stereo methods assume \emph{distant} directional lights, in which light sources are placed infinitely far away from the scene, it is desirable in practice to work with a \emph{near-light} setting where light sources are placed nearby the scene.
\newcommand\imgsize{0.18}
\newcommand\imgsizew{0.2}
\begin{figure}
	\centering
	\input{figures/intro/teaser}
	\caption{Given near light image observations and calibrated light positions, our method recovers accurate shapes with preserving the depth edges as highlighted in the close-up views. In addition, our method is robust against the depth initialization $z_0$ compared to the state-of-the-art methods.
	}
	\label{fig:teaser}
\end{figure}

Given near-light image observations and calibrated point light positions, near-light photometric stereo~(NLPS) aims at recovering the depth, surface normal, and reflectance at each scene point. Since a surface normal is perpendicular to the surface tangent plane modeled by depth partial derivatives, the NLPS problem naturally involves differentiation of the surface to associate it with the surface normal.
Previous NLPS methods~\cite{queau2018led,logothetis2017semi,santo2020deep,logothetis2020cnn} represent depth and surface normal as a grid map in a discrete manner and rely on \emph{finite differentiation} to approximate the depth partial derivatives. However, the approximation does not hold well at the sharp depth edges, leading to inconsistent estimates of the surface normal and depth.

To avoid finite differentiation and achieve edge-preserving NLPS, this paper proposes the use of \emph{analytically differentiable representation} of surfaces.
As shown in \fref{fig:teaser}, the proposed method can faithfully recover the shape and surface normal, particularly better at the depth discontinuities compared to the existing state-of-the-art method~\cite{queau2018led}.
In our method, we represent the depth as an analytical function of the image coordinates, where the partial depth derivatives are modeled by the analytical expression of the function derivatives.
In this way, consistent surface normal and depth can be obtained from the analytical function without relying on finite differentiation.
Besides ensuring the depth-normal consistency, the analytical depth function is effective for representing complex and sharp depth edges. Specifically, we use a \emph{neural surface} representation based on a differentiable neural network as the analytical depth function. With the neural surface, our NLPS method is capable of detailed shape recovery with edge preservation.

In addition, by treating the albedo as a \emph{dependent} variable resulting from the surface normal and depth, our method is made robust against inaccurate surface initialization. Compared to previous NLPS approaches that require a careful shape initialization, our method empirically exhibits preferable convergence to the accurate shape as shown in \fref{fig:teaser} (bottom) even with diverse initial shapes.

To summarize, we present an accurate NLPS method by making two technical contributions:
We propose the use of an analytical neural surface representation in NLPS for accurate shape recovery, particularly effective at the depth discontinuities.
In addition, by treating albedos as dependent variables, we frame NLPS as an optimization of the neural surface parameters only, making our method robust against diverse initial guesses.

\section{Related Works}
\label{sec:related_work}
From the early works of Iwahori~\emph{et al}\onedot~\cite{iwahori1990reconstructing} and Clark~\cite{clark1992active}, NLPS has been continuously studied. NLPS is a non-linear problem since the surface position and light fall-off of light sources are coupled with the surface normal. Even with the Lambertian assumption and calibrated settings where the light positions are known, the problem remains difficult due to the non-linear nature of the problem.

To solve the problem, previous approaches cast the problem as a non-linear optimization~\cite{logothetis2020cnn,ahmad2014improved,bony2013tridimensional,collins20123d,huang2015near,nie2016novel,yeh2016streamlined}, in which surface normals are first estimated and depth maps are then recovered by surface normal integration techniques~\cite{xie2014surface,queau2018normal}, or use variational methods~\cite{logothetis2017semi,mecca2016single,queau2018led,mecca2014near,mecca2015realistic,liu2018near} to jointly solve for surface normals and depths via partial differential equations.
To handle non-Lambertian surfaces, NLPS methods based on the Blinn-Phong reflectance model~\cite{logothetis2017semi} and neural representation of reflectances~\cite{santo2020deep,logothetis2020cnn} have also been proposed.

In the past, the problem of depth-edge preservation in NLPS has drawn little attention despite of its importance for accurate shape recovery.
Indeed, based on the evaluation by Mecca~\emph{et al}\onedot~\cite{mecca2021luces} on their real-world near-light photometric stereo dataset, inaccurate estimates near depth discontinuities turned out to be the main error source of existing NLPS methods.
There has been a work that exploits the sparsity of depth discontinuities and uses $L_1$ minimization to improve the robustness of NLPS against the discontinuities~\cite{mecca2016single}.
While their method is mathematically solid, the sparse discontinuity assumption is limited to model the real world discontinuous surfaces, such as the stairs\footnote{Results shown in the supplementary materials}, where the inaccurate finite differences along the edges cannot be treated as sparse outliers.
We consider that the error source at the depth discontinuities is due to the use of finite differentiation and propose to use an analytical surface representation, with which we can compute exact derivatives.

Another largely overlooked but important issue in NLPS is its sensitivity to the initial surface given to the solution methods. To obtain a good initial guess, Liu~\emph{et al}\onedot~\cite{liu2018near} use differential images obtained under a circular LED board. While it requires a specialized hardware, they have shown accurate shape recovery in the NLPS setting. In our method, we show that by treating albedos as dependent variables, the sensitivity to the initial guess is significantly relaxed.

\begin{figure*}
	\includegraphics[width = 1\linewidth, trim={0px 15px 0px 0px},clip]{figures/pipeline.pdf}
	\caption{Pipeline of our method. The green and blue boxes show the inputs and outputs of our method, respectively.
		Following the blue arrows, we use a neural surface model that takes image coordinates as input and outputs the corresponding depth. The surface normal and albedo are derived from the depth and its analytical derivatives internally, which are used for assessing the reconstruction loss.

		Following the green arrows, we supervise the unknown neural surface parameters $\bm{\theta}$ by the difference between input image observations and the corresponding reconstructed ones.}
	\label{fig:pipeline}
	\vspace{-0.5em}
\end{figure*}

Our method is also related to analytical surface representations. In the context of shape from shading and surface normal integration, there have been works that use a Fourier basis representation~\cite{frankot1988method} and Shapelet representation~\cite{kovesi2005shapelets}.
More recently, there are deep neural network-based differentiable surface representations, such as DeepSDF~\cite{park2019deepsdf},  DISN~\cite{xu2019disn}, and LDIF~\cite{genova2020local} that are used for shape reconstruction and completion tasks.
Sitzmann~\emph{et al}\onedot~\cite{sitzmann2020implicit} represent surface shapes with fully connected neural networks, {\sc Siren}, with periodic trigonometric functions as the activation. Their representation is differentiable and shown to have high representation power for fitting complicated signals.
These network-based surface representations have not been applied in the context of photometric stereo so far, but we are going to show their usefulness in this paper, particularly for modeling depth discontinuities.

\section{Proposed Method} \label{sec:method}
Our method takes image observations under calibrated near-point lights as input and recovers the albedo, surface normal, and depth of the scene.
Using a neural surface model, the depth, surface normal, and albedo can all be represented by the same set of neural surface parameters $\bm{\theta}$, which are the only unknowns in our NLPS method.
In this paper, we limit our method to assuming the Lambertian reflectance model for the purpose of demonstrating the effectiveness of the neural surface for depth edge preservation.

The overall pipeline of the proposed method is depicted in \fref{fig:pipeline}.
In the forward pass~(blue arrows), the neural surface model takes one point in the image coordinates as input and outputs the depth and its analytical derivatives at the point simultaneously, from which we can obtain the surface normal.
The albedo in our method is modeled as a dependent variable of the surface normal and depth. Specifically, given image observations and the shading computed from the surface normal and depth in the forward pass, the albedo is computed by minimizing the distance between the shading and image observations under the Lambertian model.
Combining the depth, surface normal, and albedo, we reconstruct the image observations based on the near-light image formation model. In the backward pass~(green arrows), the unknown network parameters $\bm{\theta}$ are self-supervised by evaluating the reconstruction loss in a similar spirit to Taniai and Maehara's method~\cite{Taniai18}.

Throughout this paper, function \hbox{$\gamma(\cdot): \mathbb{R}^{3} \rightarrow S^{2} \; (\subset \mathbb{R}^3)$} denotes the normalization of a 3D vector, \emph{i.e}\onedot} \def\Ie{\emph{I.e}\onedot, \hbox{$\gamma(\V{x}) = \frac{\V{x}}{\|\V{x}\|_2}$}.

\subsection{Near-light Image Formation Model}\label{subsec:nl_image_formation}
In NLPS, observations of a scene point is related to its albedo, surface normal, and light source positions. In this section, we first describe the geometric relationship among surface normal, depth, and scene point positions under the perspective projection, followed by the near-light image formation model.
\paragraph{Relationship between depth and surface normal }
Denote \hbox{$\V{p} = \left[u, v\right]^\top \in \mathbb{R}^2$} as a pixel location in the image coordinates, under perspective projection, its corresponding 3D scene point \hbox{$\V{x} \in \mathbb{R}^3$} in the world coordinates is written as
\begin{eqnarray}
	\V{x} = \left[\frac{z}{f}u, \frac{z}{f}v, z \right]^\top = \left[\frac{z}{f}\V{p}^\top, z \right]^\top,
	\label{eq:x_repre_pers}
\end{eqnarray}
where \hbox{$z \in \mathbb{R}$} is the depth value at \hbox{$\V{p}$}, and $f$ is the camera's focal length.

Surface normal \hbox{$\V{n} \in S^{2} \subset \mathbb{R}^3$} is a unit vector that is perpendicular to the tangent plane at $\V{x}$.
Following Qu{\'e}au~\emph{et al}\onedot\cite{queau2018normal}, the surface normal under perspective projections is written as
\begin{eqnarray}
	\V{n} = \gamma \left( \begin{bmatrix}
		f\nabla z,\\
		-z - \nabla z^\top\V{p}
	\end{bmatrix}\right),
	\label{eq:n_repre_pers}
\end{eqnarray}
where \hbox{$\nabla z = \left[\frac{\partial z}{\partial u}, \frac{\partial z}{\partial v}\right]^\top$} is the partial derivatives of the depth.
Our method can work with both orthogonal and perspective projections. From a practical viewpoint, we use the perspective camera model in the rest of the paper.

\paragraph{Near-light image formation}
Under the near-light setting, the light direction at a scene point $\V{x} \in \mathbb{R}^3$ is given by
\begin{eqnarray}
	\V{l} = \gamma(\V{q} - \V{x}),
\end{eqnarray}
where $\V{q} \in \mathbb{R}^3$ is the light position. It contributes the shading $s \in \mathbb{R}_+$ on $\V{p}$ as
\begin{eqnarray}
	s = \Phi \frac{1}{\|\V{q} - \V{x} \|_2^2} {\rm max}(\V{l}^\top \V{n}, 0),
\end{eqnarray}
where \hbox{$\rm max(\cdot, 0)$} accounts for attached shadows, $\frac{1}{\|\V{q} - \V{x} \|_2^2}$ models the light fall-off, $\Phi \in \mathbb{R}_+$ is the radiant intensity of the light source.
For anisotropic light sources, the radiant intensity is modeled by~\cite{mecca2016single,queau2018led}
\begin{eqnarray}
	\Phi = \Phi_0 (\V{l}^\top \bm{\omega})^\mu,
	\label{eq:phi_repre}
\end{eqnarray}
where the radiant parameters $\Phi_0$, $\mu$, and $\bm{\omega}$ are the light irradiance, principal direction and the attenuation parameters. Similar to previous works~\cite{queau2018led,park2014calibrating}, we assume both light source positions and radiant parameters are known from light calibration.
Combining Eqs.~(\ref{eq:x_repre_pers}) to (\ref{eq:phi_repre}) and removing the redundant variables including $\V{l}, \V{n}$, and $\V{x}$, the shading $s$ becomes a function $\mathcal{S}$ of pixel position $\V{p}$, point light source position $\V{q}$, depth $z$, and its derivatives $\nabla z$, \emph{i.e}\onedot} \def\Ie{\emph{I.e}\onedot,
\begin{eqnarray}
	s = \mathcal{S}(\V{p}, \V{q}, z, \nabla z),
	\label{eq:shading_func}
\end{eqnarray}
where the radiant parameters ($\Phi_0$, $\mu$, and $\bm{\omega}$) and camera's focal length $f$ are constant and thus omitted

If the global illumination effects, \emph{e.g}\onedot} \def\Eg{\emph{E.g}\onedot, cast shadows and inter-reflections, are negligible, and the camera has a linear response, then the Lambertian image observation at pixel $\V{p}$ under the near point light at $\V{q}$ can be written as
\begin{eqnarray}
	m_{\V{p},\V{q}} = \rho_\V{p}\mathcal{S}\left(\V{p}, \V{q}, z_\V{p}, \nabla z_\V{p}\right),
	\label{eq:nl_rendering}
\end{eqnarray}
where $\rho_\V{p} \in \mathbb{R}_{+}$ is the diffuse albedo.
Given image observations and calibrated light source positions, NLPS aims at recovering depth and albedo via minimizing
\begin{eqnarray}
	\label{eq:energy}
	\begin{aligned}
		(\V{z}^*, &\bm{\rho}^*)=
		\operatornamewithlimits{argmin}\limits_{\V{z}, \bm{\rho}} \sum_\V{p, q} \left( m_{\V{p}, \V{q}} -  \rho_\V{p}\mathcal{S}(\V{p}, \V{q}, z_\V{p}, \nabla z_\V{p})\right)^2.
	\end{aligned}
\end{eqnarray}

Our NLPS method uses a similar energy function to previous methods but represents both depth and albedo with neural surface parameters, as we will show in the following subsection.

\subsection{Edge-preserving Near-light Photometric Stereo}\label{subsec:nlps}
\begin{figure}
	\input{figures/intro/diff_comp_stair}
	\caption{Illustration of finite and analytical differentiation at a near-edge scene point $\V{p}$ shown in blue. The finite differentiation results in inaccurate derivatives $\nabla z_\V{p}$ and surface normals $\V{n}_\V{p}$ along depth edges. Analytical surface representation~(\emph{e.g}\onedot} \def\Eg{\emph{E.g}\onedot, product of sigmoid functions $\sigma(\cdot)$) provides consistent analytical derivatives and surface normals to the depth, which could be more accurate with a proper setting of parameter $k$.}
	\vspace{-1em}
	\label{fig:motivation}
\end{figure}

In this section, we introduce our NLPS with a neural surface model to handle sharp edges and solve the neural surface parameters with the reconstruction loss.

We begin with depicting the distinction between finite and analytical surface differentiations.
\Fref{fig:motivation} shows a simple stair surface represented in a discrete and an analytical manner, respectively. The depth derivatives for a near-edge scene point $\V{p}$ are approximated inaccurately via the finite difference in the discrete surface model, leading to inconsistent depth and surface normal. With analytical surface representation, where the stair surface is represented by the product of two sigmoid functions $\sigma(\cdot)$ in this particular example,
the surface normal and depth are guaranteed to be consistent for every scene point from the analytical expression, and there is no approximation in computing the analytical depth derivatives.

Our neural surface belongs to analytical surface representation and is empowered by flexibility of neural networks to model sharp edges. We represent the surface depth as an analytical neural function of 2D image coordinates $\mathcal{Z}$, \emph{i.e}\onedot} \def\Ie{\emph{I.e}\onedot, \hbox{$z_\V{p} = \mathcal{Z}(\V{p}; \bm{\theta})$}, where $\bm{\theta}$ encodes all the network parameters.
As the analytical neural surface is differentiable w.r.t\onedot} \def\dof{d.o.f\onedot the pixel position, the first order partial derivatives of the depth $\nabla z_\V{p}$ can be exactly calculated as
\begin{eqnarray}
	\nabla z_\V{p} = \begin{pmatrix}
		\mathcal{Z}_u(\V{p}; \bm{\theta})\\
		\mathcal{Z}_v(\V{p}; \bm{\theta})
	\end{pmatrix} = \nabla \mathcal{Z}(\V{p}; \bm{\theta}),
	\label{eq:par_derivative}
\end{eqnarray}
which is also an analytical function of the neural surface parameters $\bm{\theta}$. Therefore, the surface normal from the depth partial derivatives can be obtained together with the depth (see \eref{eq:n_repre_pers}) from the same set of parameters.
If the neural surface is sufficiently flexible to represent the true depth, both the surface normal and depth can be accurately represented by the network parameters, including the areas with sharp edges and high-frequency curvatures.

Theoretically, any analytical surface models can be used in our NLPS method. In this paper, we use {\sc Siren}~\cite{sitzmann2020implicit} as our neural surface model, which has a strength in modeling finely detailed signals.
Taking a single {\sc Siren} neuron as an example, the depth is represented by a weighted sum of a set of sine functions with varying frequencies as
\begin{eqnarray}
	\mathcal{Z}(\V{p}; \bm{\theta}) = \V{w}_1^\top\sin(\V{W}_2\V{p} + \V{b}_2) + b_1,
	\label{eq:siren}
\end{eqnarray}
where $\V{w}_1 \in \mathbb{R}^{k}$ and $b_1 \in \mathbb{R}$ are the coefficients and bias of the sine functions, respectively, and $\V{W}_2 \in \mathbb{R}^{k \times 2}$ and $\V{b}_2 \in \mathbb{R}^{k}$ encode the $k$ diverse frequencies and phases in the sine functions. All these parameters are embedded in $\bm{\theta}$.
With more neurons in the network, we can represent high-frequency curvatures such as sharp edges. As the {\sc Siren} network is differentiable, we can obtain the analytical depth derivatives as
\begin{eqnarray}

	\nabla \mathcal{Z}(\V{p}; \bm{\theta}) = \V{W}_2^\top{\rm diag}(\cos(\V{W}_2\V{p} + \V{b}_2))\V{w}_1,
	\label{eq:siren_derivative}
\end{eqnarray}
where ${\rm diag(\cdot)}$ is a diagonalization operator. Based on the analytical derivatives, the surface normal vector can be obtained following \eref{eq:n_repre_pers}.

\paragraph{Reconstruction loss}
We use the near-light image formation model to optimize the neural surface parameters $\bm{\theta}$ by evaluating the reconstruction loss.
Our method treats albedos that appear in the image formation model as dependent variables of surface normals and depths. Thus, the albedos are also governed by the neural surface parameters $\bm{\theta}$.

By rewriting the Lambertian near-light image formation model of \eref{eq:nl_rendering} with neural surface parameters $\bm{\theta}$, we have
\begin{eqnarray}
	\begin{aligned}
		m_{\V{p},\V{q}}
		&= \rho_\V{p} \mathcal{T}(\V{p}, \V{q}, \mathcal{Z}(\V{p}; \bm{\theta}), \nabla \mathcal{Z}(\V{p}; \bm{\theta}))\\
		&\equiv \rho_\V{p} \mathcal{T}(\V{p}, \V{q}; \bm{\theta}).
	\end{aligned}
	\label{eq:img_formation_siren}
\end{eqnarray}
Under the illumination of $f$ near-point lights, we have a vector of image observations \hbox{$\V{m}_\V{p} = \left[m_{\V{p}, \V{q}_1}, \cdots, m_{\V{p}, \V{q}_f}  \right]^\top$}. The corresponding shading vector is obtained by \hbox{$\V{s}_\V{p} = \left[\mathcal{S}(\V{p}, \V{q}_1; \bm{\theta}), \cdots, \mathcal{S}(\V{p}, \V{q}_f; \bm{\theta})\right]^\top$}.
From the measurement and shading vectors, we obtain the least-squares approximate albedo $\hat{\rho}_\V{p}$ as
\begin{eqnarray}
	\hat{\rho}_\V{p} = \frac{\V{m}_\V{p}^\top \V{s}_\V{p}}{\V{s}_\V{p}^\top \V{s}_\V{p}}.
	\label{eq:albedo_lsqr}
\end{eqnarray}
Because the shading $\V{s}_{\V{p}}$ is a function of the neural surface parameters $\bm{\theta}$ and the image observations $\V{m}_\V{p}$ are constant, the albedo only depends on the network parameters $\bm{\theta}$. In this manner, the NLPS optimization shown in \eref{eq:energy} reduces from depth and albedo to the neural surface parameters $\bm{\theta}$ only.

Based on the the least-squares approximate albedo, surface normal, and depth, we reconstruct the images based on \eref{eq:img_formation_siren}. The reconstruction loss is evaluated by the $L_1$ distance between input image observations and the reconstructed ones as
\begin{eqnarray}
	\mathcal{L} = \frac{1}{pf}\sum_\V{p, q} \left| m_{\V{p}, \V{q}} -  \hat{\rho}_\V{p} \mathcal{S}(\V{s}, \V{p}; \bm{\theta}) \right|,
	\label{eq:loss_ours}
\end{eqnarray}
where $p$ is the number of pixels.
Supervised by the reconstruction loss, we update the neural surface parameters $\bm{\theta}$ in the backward process until convergence. From optimized neural surface parameters, the surface normal, depth, and albedo can be reconstructed accordingly. Empirically, our loss based on the albedos as dependent variables exhibits robustness against the initial guess, as we will see in the experiment section.

\paragraph{Implementation}
Our neural surface model consists of $5$ fully-connected hidden layers with a sine activation function and $1$ linear output layer. Each layer contains $256$ channels.
Overall, this $6$-layer network is rather lightweight with $0.3$M learnable parameters compared to the non-parametric depth map representation~\cite{santo2020deep}.
We initialize the network parameters $\bm{\theta}$ following the setting of {\sc Siren}~\cite{sitzmann2020implicit}. The image coordinates in the network are scaled to the range of $[-1, 1]$.
We adopt the Adam optimizer~\cite{kingma2014adam} with default settings ($\beta_1 = 0.9$ and $\beta_2 = 0.99$). The learning rate is initially set to $1 \times 10^{-4}$ and divided by $2$ at every $8000$ iterations. The optimization is terminated when the reconstruction loss becomes lower than $1 \times 10^{-6}$.
Besides, to ignore the influence of cast shadows, we discard shadowed pixels based on a thresholding strategy similar to~\cite{shi2019benchmark}, \emph{i.e}\onedot} \def\Ie{\emph{I.e}\onedot, discard the pixels with intensities less than $5\%$ of the median of the intensities in each image.
Please refer to our supplementary material for more details.

\renewcommand\imgsize{0.2}
\renewcommand\imgsizew{0.2}
\begin{figure*}
	\centering

	\input{figures/exp/synthetic_data}
	\caption{Synthetic near-light image dataset in our experiment.}
		\vspace{-1em}
	\label{fig:synthetic_data}
\end{figure*}

\section{Experiments}
We evaluate our method on both synthetic and real-world datasets. We choose QD18~\cite{mecca2016single} and LB20~\cite{logothetis2020cnn} as the baseline methods, which are the state-of-the-art NLPS methods for Lambertian and non-Lambertian reflectances.
Additional comparisons with MQ16~\cite{mecca2016single} and SM20~\cite{santo2020deep} are summarized in the supplementary material.
Following the initialization setting of the baseline methods, we use a plane located at the mean distance between the object and camera as the initial shape for the existing method.

\subsection{Experiments on Synthetic Dataset}
We render five synthetic objects shown in \fref{fig:synthetic_data} with a Lambertian reflectance using the renderer Blender 2.80~\cite{blendercite}.
The camera is placed at the world origin with focal length and image resolution of $50$~mm and $512 \times 512$, respectively. To synthesize realistic appearances, the renderings include cast shadows.
For the lighting condition, we use $81$ point light sources arranged in a $9 \times 9$ regular grid with a uniform intensity~($\mu = 0, \Phi_0 = 1$). The light source locations are in the range of $(X, Y, Z) = (\pm 1, \pm 1, 0)$, with the unit of meter. The object is scaled and roughly located in the range of $(X, Y, Z) = (\pm 1, \pm 1, 3 \pm 0.5)$.

The comparison with the baseline methods is shown in \fref{fig:synthetic_res}. From the ground-truth (GT) shape, we can observe that the stair region in the {\sc Tent}, the ear part of the {\sc Bunny}, and the arm and foot areas of the {\sc Buddha} contain depth discontinuities.
Our method shows the strength of depth edge preservation in such regions compared to the baseline methods, and yields shapes that are close to GTs.
From {\sc Bunny}'s error distribution, we observe that the estimation error around the ear region does not influence the shape recovery at the surrounding area with our method.
As summarized in \Tref{table:syn_eval}, our method achieves smaller mean angular errors~(MAngE) of the surface normal and the mean absolute errors~(MAbsE) of the depth compared with existing NLPS methods.

\begin{figure*}
	\input{figures/exp/synthetic_comp}
	\caption{Comparison with QD18~\cite{queau2018led} and LB20~\cite{logothetis2020cnn} on synthetic data. Left side shows the GT and estimated shapes and surface normals. The right side gives the corresponding error distributions. Results and error distributions of SM20~\cite{santo2020deep} and MQ16~\cite{mecca2016single} are provided in supplementary materials.
	}
	\label{fig:synthetic_res}
	\vspace{-2em}
\end{figure*}

\begin{table}
	\centering
	\caption{Summary of depth and surface normal estimation errors.}
	\resizebox{0.95\textwidth}{!}{
	\begin{threeparttable}
			\begin{tabular}{ccccccccccc}
				\toprule
				\multirow{2}{*}{Object} & \multicolumn{2}{c}{QD18~\cite{queau2018led}} & \multicolumn{2}{c}{LB20~\cite{logothetis2020cnn}} & \multicolumn{2}{c}{SM20~\cite{santo2020deep}} & \multicolumn{2}{c}{MQ16~\cite{mecca2016single}} & \multicolumn{2}{c}{Ours} \\
				\cmidrule(l){2-3} \cmidrule(l){4-5} \cmidrule(l){6-7} \cmidrule(l){8-9} \cmidrule(l){10-11}
				& MAngE\tnote{1} & MAbsE\tnote{2} &  MAngE & MAbsE& MAngE & MAbsE & MAngE & MAbsE & MAngE & MAbsE \\
				\midrule
				{\sc Tent} & 5.41 & 55.2 & 2.29 & 93.5  & 9.99 & 371.1 & 10.99 & 111.3 & 1.72 & 2.68 \\
				{\sc Bunny} & 1.66 & 24.1 & 3.94 & 30.8  & 7.43 & 57.9 & 8.54 & 60.0 & 0.33 & 2.73 \\
				{\sc Buddha} & 7.84 & 70.9 & 4.44 & 129.1 & 12.19 & 149.2 & 10.44 & 97.2 & 2.11 & 9.00 \\
				Average & 4.97 & 50.1 & 3.57 & 84.5 & 9.87 & 192.7 & 9.98 & 89.5 & \textbf{1.39} & \textbf{4.80} \\
				\bottomrule
			\end{tabular}
		\begin{tablenotes}[para]
			\item[1] MAngE unit: Degree
			\item[2] MAbsE unit: mm
		\end{tablenotes}
	\end{threeparttable}
	}
	\label{table:syn_eval}

\end{table}

\paragraph{Effectiveness of analytical derivatives}
To assess the effectiveness of the analytical differentiation over finite differentiation, we compare our method with the version where the analytical derivatives are replaced by finite differences calculated from depth estimates in each forward pass.
The comparison is summarized in \fref{fig:finite_diff_ablation}.
Compared to our method with the analytical derivatives, the method with finite differences shows greater errors. In particular, our method based on analytical derivatives shows faithful recovery around the depth discontinuities.
\begin{figure}

	\input{figures/exp/ablation_finite}
	\vspace{-0.2em}
	\caption{Reconstructed shapes by our method with finite difference~(left) and analytical derivative~(right). Sharp edges are well-preserved using analytical derivatives. The depth MAbsE in mm is shown on the top of each shape estimate.
	}
	\label{fig:finite_diff_ablation}
\end{figure}
\begin{figure}
	\vspace{-1em}
	\centering
	\input{figures/exp/initial_shape_eval}
	\caption{Evaluation of the sensitivity to varying initial depths. (\textbf{Left}) Recovered shapes of our and baseline methods under varying initial depths, where the GT shape is shown in light green. The result of our method is unchanged regardless of the initial depths in this range. (\textbf{Right}) Quantitative evaluations of the surface normal and depth under different initial depth guesses $z_0$.}
	\label{fig:initial_eval}
	\vspace{-1.5em}
\end{figure}

\paragraph{Robustness against depth initialization}
In our method, the initial shape is determined by the initialization of network parameters. We use the initialization strategy of the {\sc Siren}~\cite{sitzmann2020implicit} network, with which the initial depth follows a normal distribution centered at an offset.
The initial depth offset is controlled by the initial bias value of the output layer/neurons.
To evaluate the robustness of our method against the depth initialization, we vary the initial depth offset $\{z_0\}$ and evaluate the shapes recovered by the baseline and our methods. To eliminate the influence of discontinuities to the baseline methods, we choose a smooth shape in this experiment.

Under the varying initial depths in a relatively large range, our method always converges to the same shape estimation, which consistently overlaps with the GT shape as shown in \fref{fig:initial_eval}.
From the estimation error of surface normal and depth shown in the plots of \fref{fig:initial_eval}, our method is not sensitive to the initial shape as our method jointly optimizes the surface shape and albedo by only updating the neural surface parameters.
Compared to the ground truth, the recovered shapes from LB20~\cite{logothetis2020cnn} and QD18~\cite{queau2018led} become either flat~($z_0 = 1.5\,$m) or inflating~($z_0 = 3.5\,$m) depending on the initial depth settings.
When the depth is initialized as the mean distance between the target object and the camera~($z_0 = 2.5\,$m in the experiment), the baseline methods achieve the high accuracy in the surface normal and depth estimation.

\renewcommand\imgsize{0.1}
\begin{figure*}
	\input{figures/exp/non_lambert_eval_one_col}
	\caption{Evaluation using non-Lambertian surfaces. (\textbf{Left}) Image observations and the angular error distributions under the reflectance of Lambertian diffuse, Oren–Nayar~\cite{oren1994generalization} diffuse, and the specular reflectance using Disney principled BSDF~\cite{burley2012physically}. (\textbf{Right}) Depth and surface normal estimation errors of our method under varying values of diffuse roughness $\sigma_d$ and specular roughness $\sigma_s$.}
	\label{fig:non_lambert_eval}
\end{figure*}

\paragraph{Influence of non-Lambertian reflectances}
Our NLPS method assumes Lambertian diffuse surfaces.
To evaluate the influence of non-Lambertian reflectances, we test our method using a more general diffuse reflectance rendered by Oren–Nayar model~\cite{oren1994generalization}, and also the specular reflectance modeled by Disney principled BSDFs~\cite{burley2012physically}. We render the image observations with varying diffuse roughness $\sigma_d$ and specular roughness $\sigma_s$ values of the two reflectance models, and evaluate the influence of non-Lambertian reflectances on our method.

\Fref{fig:non_lambert_eval} (left) shows the image observations under Lambertian diffuse reflectance, Oren–Nayar reflectance, and Disney principled specular reflectance based on different settings of $\sigma_d$ and $\sigma_s$.
From the error distribution of the surface normal estimates, Oren–Nayar reflectance brings errors to surface normals with large elevation angles, and specular reflectance influences the area where specular highlights are observed.
The estimation errors of our method under varying roughnesses are shown on the right side. As expected, the surface normal and depth estimation accuracies decrease with the reflectance deviating from the Lambertian reflectance. However, the influences of the non-Lambertian reflectance are rather limited in this experiment. The surface normal estimation error increases from $0.33\degree$ to less than $2.4\degree$. The depth error increase from $2.73$~mm to $40$~mm for the {\sc Bunny} object with the size of $2$~m.

The accuracy of our NLPS method for non-Lambertian scenes has also been tested using real dataset LUCES~\cite{mecca2021luces} containing diverse materials. The results presented in the supplementary material show that our method yields reasonable shape recoveries for a set of non-Lambertian surfaces.

\subsection{Experiments on Real-world Dataset}
Besides the synthetic evaluation, we also test our method using real captured data to assess our method on real scenarios. In this section, we first introduce our hardware setup for near-light image data capture, then we compare the shape recovery results with the baseline methods.

\paragraph{Hardware setup} As shown in \fref{fig:hardware_setup}, we build a device for capturing near-light image observations, in which the LED positions and object size are designed to ensure the near-light setting. We calibrate the LED positions and the intrinsics of our camera~(FLIR BFS-U3-123S6C-C) with a $16$~mm lens. Since all the LEDs are of the same product\footnote{Normand SC6812RGBW LED, \url{http://www.normandled.com/Product/view/id/883.html}. Retrieved March 7th, 2022.}, we assume they share the same radiant parameters~(\hbox{$\Phi_0 = 1, \mu = 0.574$}).
\renewcommand\imgsize{0.2}
\begin{figure*}[t]
	\centering
	\includegraphics[width=0.75\textwidth]{figures/hardware.pdf}
	\caption{Hardware setup for near-light photometric stereo. The object size and the LED to object distance are designed to maintain a near light illumination. Green area indicates the LED droids used for our data capturing.}
	\label{fig:hardware_setup}
	\vspace{-1em}
\end{figure*}

\begin{figure}
	\vspace{-1em}
	\scriptsize
	\makebox[0.12\textwidth]{\quad Near-light images}
	\makebox[0.33\textwidth]{\quad Surface normal recovery}
	\makebox[0.1\textwidth]{\qquad {Object appearance}}
	\makebox[0.3\textwidth]{\qquad\qquad\qquad\quad Surface shape recovery}
	\\
	{\centering\includegraphics[width = 1\linewidth, trim={0px 15px 0px 0px},clip]{figures/real_flir_show_v2.pdf}}
	\\
	\makebox[0.08\textwidth]{}
	\makebox[0.11\textwidth]{\qquad\qquad\quad QD18~\cite{queau2018led}}
	\makebox[0.11\textwidth]{\qquad\qquad LB20~\cite{logothetis2020cnn}}
	\makebox[0.12\textwidth]{\qquad\quad Ours}
	\makebox[0.16\textwidth]{}
	\makebox[0.11\textwidth]{\quad QD18~\cite{queau2018led}}
	\makebox[0.11\textwidth]{\qquad\quad LB20~\cite{logothetis2020cnn}}
	\makebox[0.11\textwidth]{\qquad\qquad Ours}
	\caption{Comparison on real data. Values in blue boxes give the measured distance~(object appearance column) and the estimated ones~(shape recovery columns) of two scene points labeled by green dots, revealing the shape estimation accuracy near the discontinuity.}
	\label{fig:real_exp}
		\vspace{-1em}
\end{figure}

\paragraph{Evaluation}
As shown in \fref{fig:real_exp}, we capture three surfaces and compare the surface normal and 3D shape recovery with the baseline methods. For all the objects, the initial depth for QD18~\cite{queau2018led} and LB20~\cite{logothetis2020cnn} are set to $400$~mm, which is close to the true object depth. Based on the visualization of recovered 3D shapes, our method yields more reasonable shape recoveries particularly near depth discontinuities, such as the step area of {\sc Stair}, the wing and neck regions of {\sc Angel}, and the book region of {\sc Plato}. We measure the distance between two scene points of the real surface, as shown in the object appearance column of \fref{fig:real_exp}. The distances between the same two points on our recovered shapes are closer to the measured ones, showing our strength over the baseline methods on shape recovery with edge preservation.
\paragraph{Results on LUCES} We also present a quantitative evaluation of our method on a public near-light photometric stereo dataset LUCES~\cite{mecca2021luces} containing $14$ objects with diverse shapes and materials.
Compared to existing methods on the benchmark~\cite{mecca2021luces}, our method achieved more accurate surface normal and relative depth estimates on $12$ objects in average, except for two metallic surfaces {\sc Bell} and {Cup} that significantly deviate from the Lambertian assumption. More detailed analyses can be found in our supplementary material.

\section{Conclusion}
In this paper, we propose a NLPS method to recover detailed surface shapes with an emphasis on depth edge preservation.
The finite difference approximation used in existing NLPS methods is inaccurate to model the depth derivatives along the depth discontinuities, leading to shape distortions.
Our method avoids the problem by introducing an analytical neural surface representation in NLPS, where depth derivatives can be analytically derived.
Besides, by treating albedos as dependent variables of surface normal and depth under the Lambertian reflectance assumption, we cast NLPS as an optimization of the neural surface parameter only, making our method robust against the initial depth.
Based on the experiments,
our method shows faithful shape estimates with preserving depth discontinuities and is less sensitive to the initial depth guess.

\paragraph{Limitations}
This paper focuses on the geometric aspect of NLPS by proposing an edge-preserving NLPS based on neural surface representation. Although the reconstruction loss in our NLPS method is based on the Lambertian assumption to gain robustness against depth initialization, it is certainly preferable to be able to deal with non-Lambertian reflectances. One potential direction for our future study would be incorporating a parametric/neural reflectance model to represent non-Lambertian reflectances, such as Spherical Gaussian bases~\cite{wang2009all} and MLPs applied in recent multi-view inverse rendering techniques~\cite{zhang2021physg,zhang2021nerfactor}. By optimizing both the reflectance and neural surface parameters using the image reconstruction loss, the surface shape and non-Lambertian reflectances may be jointly recovered.

\clearpage
\bibliographystyle{splncs04}


\section{Introduction}
\defP_\text{miss}{P_\text{miss}}
\defP_\text{fa}{P_\text{fa}}
\def\bar P_\text{miss}{\bar P_\text{miss}}
\def\bar P_\text{fa}{\bar P_\text{fa}}
\def\tilde P_\text{miss}{\tilde P_\text{miss}}
\def\tilde P_\text{fa}{\tilde P_\text{fa}}
\def\text{accept}{\text{accept}}
\def\text{reject}{\text{reject}}
\defC_\text{miss}{C_\text{miss}}
\defC_\text{fa}{C_\text{fa}}

This is a position paper and tutorial about the decision stage of speaker verification and how to quantify verification accuracy. Our position is:
\begin{itemize}
	\item Bayes decisions are preferable to ad-hoc alternatives.
	\item The Bayes error-rate (the accuracy of Bayes decisions) is a good representation of the accuracy of the verifier.
\end{itemize}
A \emph{speaker verification trial} provides two speech samples that may have been spoken by one-and-the-same speaker (hypothesis $H_1$), or by two different speakers ($H_2$). It is required to make an accept/reject decision, where \emph{accept} favours $H_1$ and \emph{reject} favours $H_2$. The speech input of the trial is processed by a speaker verifier that outputs a \emph{score}, $s\in\mathbb{R}$, where by convention, more positive $s$ supports $H_1$, while more negative $s$ supports $H_2$. For some verifiers, this is all that can be said of the scores and such scores are termed \emph{uncalibrated}. Some verifiers output their scores in (log) likelihood-ratio format, termed \emph{calibrated}. Uncalibrated scores can be post-calibrated by adding a calibration stage to the verifier.

Bayes decisions can be made with either calibrated, or uncalibrated scores as will be explained in this tutorial. The former method provides the user with more flexibility and allows for more informative representation of the verifier accuracy. Decisions \emph{can} also be made by comparing scores to ad-hoc thresholds, obtained e.g.\ by fixing the false-accept rate. While such methods avoid both likelihood-ratio calibration and specification of prior and costs by the user, we offer some strong criticisms.

The tutorial does not discuss how to calibrate scores, but rather how to make decisions given calibrated scores---and how to compute the accuracy of these decisions. We discuss accuracy measures that can be obtained by testing the verifier on a supervised evaluation database. Perhaps the most ubiquitously available accuracy statistic is the equal-error-rate (EER). We highlight a little-known relationship between the EER and the Bayes error-rate: for a well-calibrated verifier, the EER is an approximate upper bound to the Bayes error-rate. More generally, given an ROC/DET curve~\cite{DETPLOT} of the form $P_\text{miss}(P_\text{fa})$, the Bayes-error-rate for a well-calibrated verifier can be computed as a function of the prior, $P(H_1)$. Most generally, given $P_\text{miss}(\theta)$ and $P_\text{fa}(\theta)$ as functions of a score threshold, $\theta$, the actual Bayes error-rate can be computed for verifiers that may or may not be well-calibrated.

The theory in several sections below is followed by a demonstration of our methods on the recently published DCA-PLDA speaker verifier~\cite{DCA_PLDA}.

\section{Optimal Bayes decisions}
\begin{figure}[tb!]
  \centering
  \includegraphics[trim=0 10 0 10, clip, width=\linewidth]{trapezium.pdf}
  \caption{The trapezium bound: $\hat P_e\le\min(\pi,1-\pi,\text{EER})$. The axes have logit and log scales, to better show small values.}
  \label{fig:trapezium}
\end{figure}
We start with a concise summary of some well-known elements of Bayes decision theory~\cite{DeGroot70}, applied to binary classification and in particular to speaker verification~\cite{bosaris,bookchapter,NikoCSL}. In this section, we analyze Bayes decisions in the idealized case of perfect calibration. In the next section, we generalize to realistic, practical calibration.

Consider a verification trial represented as $(h,s)$, where $h\in\{H_1,H_2\}$ is the unknown hypothesis and $s\in\mathbb{R}$ is the verifier score. Given $s$, we want to make an accept/reject decision. The outcomes $(\text{accept},H_1)$ and $(\text{reject},H_2)$ are considered correct, while the two kinds of classification errors are \emph{miss}: $(\text{reject},H_1)$; and \emph{false-accept}: $(\text{accept},H_2)$. We now suppose that the decision logic has access to the joint distribution:
\begin{align}
\label{eq:joint}
P(h,s)&=P(h)P(s\mid h)
\end{align}
This implies perfect calibration: the prior, $P(h)$, typically supplied by the user, must equal the actual frequency of $H_1$ vs $H_2$ and the likelihoods $P(s\mid H_1)$ and $P(s\mid H_2)$, typically supplied in likelihood-ratio form by the verifier, must equal the actual conditional score distributions. Given these resources, we can compute the hypothesis posterior:
\begin{align}
P(h\mid s) &= \frac{P(s,h)}{P(s,H_1)+P(s,H_2)}
\end{align}
If we choose to accept or reject, the probability of error is respectively $P(H_2\mid s)$ or $P(H_1\mid s)$. So to minimize the probability of error, make the \emph{Bayes decision}:\footnote{The decision at equiprobable hypotheses can be chosen arbitrarily. }
\begin{align}
\text{decision} &=
\begin{cases}
\text{accept} & \text{if $P(H_1\mid s) \ge P(H_2\mid s)$} \\
\text{reject} & \text{if $P(H_1\mid s) \le P(H_2\mid s)$}
\end{cases}
\intertext{This can be rewritten, using basic probability rules, as:}
\label{eq:lrdecision}
\text{decision} &=
\begin{cases}
\text{accept} & \text{if $r \ge \theta_\pi$} \\
\text{reject} & \text{if $r \le \theta_\pi$}
\end{cases}
\end{align}
where $r$ is the \emph{likelihood-ratio} and $\theta_\pi$ is the \emph{Bayes threshold}:
\begin{align}
\label{eq:lr}
r &= \frac{P(s\mid H_1)}{P(s\mid H_2)} \\
\label{eq:BDT}
\theta_\pi &= \frac{P(H_2)}{P(H_1)} = \frac{1-\pi}{\pi}
\end{align}
where $\pi=P(H_1)$ is short-hand. With this optimal decision rule, the probability for a classification error is:\footnote{ The $\hat{}$ on $\hat P_e$ refers to the optimality given by perfect calibration---later, $\tilde P_e$ will be used for the actual error-rate, when perfect calibration cannot be assumed.}
\begin{align}
\label{eq:Pe1}
\begin{split}
\hat P_e(\pi) &= P(\text{reject},H_1) + P(\text{accept},H_2) \\
&= \pi P(\text{reject}\mid H_1) + (1-\pi)P(\text{accept}\mid H_2) \\
&= \pi P_\text{miss}(\theta_\pi) + (1-\pi)P_\text{fa}(\theta_\pi)
\end{split}
\end{align}
The above conditional error-rates can be expanded as:
\begin{align}
\label{eq:pmiss}
P_\text{miss}(\theta) &= P(\text{reject}\mid H_1,\theta) = \int_0^{\theta} P(r\mid H_1)\,dr \\
\label{eq:pfa}
P_\text{fa}(\theta) &= P(\text{accept}\mid H_2,\theta) = \int_{\theta}^\infty P(r\mid H_2)\,dr
\end{align}
The ROC curve can be generated\footnote{The ROC can also be generated from raw scores, $s$, or from $\log(r)$. For monotonic transforms, $s\to r$ all three ROCs are identical.} by sweeping $\pi$ from 0 to 1 and plotting $P_\text{miss}$ versus $P_\text{fa}$. As $\pi$ is increased, $P_\text{miss}$ decreases monotonically and $P_\text{fa}$ increases monotonically.

The full function, $\hat P_e(\pi)$ provides a good answer to the question of optimal verifier accuracy, but let's continue to seek a more concise summary via further analysis. If there is no prior uncertainty the error-rate vanishes: $\hat P_e(0) = \hat P_e(1)= 0$. To understand what happens for $0<\pi<1$, we differentiate $\hat P_e$ w.r.t.\ $\pi$:
\begin{align}
\label{eq:dPedP1}
\hat P_e' &= P_\text{miss} + \piP_\text{miss}' -P_\text{fa} + (1-\pi)P_\text{fa}'
\intertext{where, using~\eqref{eq:BDT} in~\eqref{eq:pmiss} and~\eqref{eq:pfa}:}
P_\text{miss}' &= \frac{dP_\text{miss}}{d\theta} \frac{d\theta}{d\pi}
= -\frac{P(\theta\mid H_1)}{\pi^2} \\
P_\text{fa}' &= \frac{dP_\text{fa}}{d\theta} \frac{d\theta}{d\pi}
= \frac{P(\theta\mid H_2)}{\pi^2}
\end{align}
To complete our derivation, we invoke the \emph{calibration property}~\cite{VanLeeuwen_2013} of the likelihood-ratio~\eqref{eq:lr}:
\begin{align}
\label{eq:calprop}
\frac{P(s \mid H_1)}{P(s \mid H_2)} &= r = \frac{P(r \mid H_1)}{P(r \mid H_2)}
\end{align}
Using this at $r=\theta=\frac{1-\pi}{\pi}$, the 2nd and 4th terms in~\eqref{eq:dPedP1} cancel, to give:
\begin{align}
\hat P'_e(\pi) &= P_\text{miss}(\theta_\pi) - P_\text{fa}(\theta_\pi)
\end{align}
After checking that $\hat P''<0$, we see that $\hat P_e$ is concave, with a unique maximum of $\text{EER}=P_\text{miss}(\theta_{\pi^*}\!)=P_\text{fa}(\theta_{\pi^*}\!)$, where the derivative vanishes at $\pi=\pi^*$:
\begin{align}
\label{eq:maxPe}
\begin{split}
\max_{\pi} \hat P_e &= \pi^*P_\text{miss}(\theta_{\pi^*}\!) + (1-\pi^*)P_\text{fa}(\theta_{\pi^*}\!)\\
&= \pi^*\text{EER} + (1-\pi^*)\text{EER} = \text{EER}
\end{split}
\end{align}
This upper-bound property of the EER is not well known. It was mentioned in~\cite{Bernardo94} and received detailed treatment in~\cite{PhD}, but the derivation above is new and we hope more intuitive. Next, we invoke another upper bound~\cite{PhD}:
\begin{align}
\hat P_e(\pi) &\le \min(\pi,1-\pi)
\end{align}
where the RHS is the probability for error when making a Bayes decision using the prior alone, while the LHS has the advantage of the extra information supplied by the score. The RHS becomes small whenever $\pi\approx0$, or $\pi\approx1$, which shows that the problem becomes easier when the prior uncertainty is low. \\

\noindent In summary of the above results, we can now provide a first answer to our question:
\begin{itemize}[leftmargin=1.5em]
\item[\textbf{Q:}] Out of a hundred trials, how many errors does your speaker verifier make?
\item[\textbf{A:}] The error-rate depends not only on the accuracy of the verifier, but also on the user-supplied prior $\pi$. For perfect calibration, the error-rate, $\hat P_e$, obeys the \emph{trapezium bound}:
\begin{align}
\label{eq:trapezium}
\hat P_e(\pi) \le \min(\pi,1-\pi,\text{EER} )
\end{align}
wherein the verifier accuracy is represented by the EER, and the user contribution by $\min(\pi,1-\pi)$. See figure~\ref{fig:trapezium} for an example.
\item[\textbf{Q:}] What if calibration is not perfect?
\item[\textbf{A:}] Calibration can be measured (see the next section), using the same resources as for the ROC, namely a supervised database of scores. Since calibration can be measured, it can be optimized, so that  the actual error-rates can get close to the optimal $\hat P_e$.
\end{itemize}

\section{Actual Bayes decisions}
\label{sec:aer}
In a real, practical application of a speaker verifier, perfect calibration cannot be assumed, neither for the user-supplied prior, nor for the system-supplied likelihood-ratio. If either of these resources are not perfectly calibrated then the optimal error-rate, $\hat P_e$ of~\eqref{eq:Pe1} becomes a lower bound to the actual error-rate. For bad calibration, the error-rate could become arbitrarily bad, up to a maximum of 1. To see this, consider for example a user that supplies $\pi=1$, when in actual fact only $H_2$ trials arrive at the verifier, in which case every decision will be an error.

We shall however dismiss the problem of imperfectly calibrated $\pi$, because in this paper, we are interested in quantifying the verifier accuracy and the verifier should not be blamed for user errors. Keep in mind that $\pi$ cannot be extracted by the verifier from the speech inputs, nor can it be learnt from a typical verifier training database, because $\pi$ is entirely dependent on the application. In what follows, we shall assume perfect $\pi$ calibration.

Now, let $P(s\mid h)$ denote the actual conditional score distributions and let $r=\frac{P(s\mid H_1)}{P(s\mid H_2)}$ represent the perfectly calibrated likelihood-ratio, which is in practice \emph{not available} to the decision logic. Instead, we assume that the decision logic has access to a \emph{calibration function}, $\tilde r = f(s)$, that is designed to give $\tilde r \approx r$. (For some systems, the score $s\approx r$ is already well-calibrated, e.g.~\cite{STBU,DCA_PLDA}. For such systems we take $f$ to be the identity function.) Other examples of calibration can be found in~\cite{NikoCSL,bosaris,cal,bayescal,usc,sandro19,sandro19b,sandro20,Ferrer:aslp18}, and in many other systems submitted to speaker recognition evaluations.

To analyze the actual error-rate that results from using $\tilde r$, we use it to replace $r$ in the decision rule~\eqref{eq:lrdecision}, while $\theta_\pi$ is still the same theoretically optimal threshold~\eqref{eq:BDT}. The resulting \emph{actual error-rate} is:\footnote{To analyze prior miscalibration: use the true hypothesis frequencies here, but a miscalibrated prior, $\tilde\pi$ to compute $\theta_{\tilde\pi}$.}
\begin{align}
\label{eq:actPe1}
\tilde P_e(\pi) &= \pi \tilde P_\text{miss}(\theta_\pi) + (1-\pi)\tilde P_\text{fa}(\theta_\pi)
\end{align}
where
\begin{align}
\tilde P_\text{miss}(\theta) &= \int_0^\theta P(\tilde r\mid H_1)\,d\tilde r \\
\tilde P_\text{fa}(\theta) &= \int_\theta^\infty P(\tilde r\mid H_2)\,d\tilde r
\end{align}
To evaluate $\tilde P_e$ in practice, the usual recipe requires the same resource as for the ROC: a supervised database of scores, where $\tilde r$ and $h$ are available for every trial. The conditionals, $P(\tilde r\mid h)$ are now in empirical form (impulses at the data points) and the integrals reduce to counting the errors that result when thresholding all calibrated scores against a set of thresholds of interest. This can be done\footnote{See implementations: \url{github.com/bsxfan/PYLLR}} efficiently by jointly sorting scores and thresholds and retrieving error-rates from the ranks of the thresholds~\cite{bosaris}.

Since generally $\tilde r\ne r$, neither the calibration property~\eqref{eq:calprop}, nor the trapezium bound~\eqref{eq:trapezium} apply to $\tilde P_e$. Since $\hat P_e$ is optimal and $\tilde P_e$ depends on a (hopefully only slightly) suboptimal decision rule, we know that:
\begin{align}
\tilde P_e(\pi) \ge \hat P_e(\pi)
\end{align}
If the calibration is good however, then $\tilde P_e \approx \hat P_e$ and the trapezium will still function as \emph{approximate} upper bound to the actual error-rate:
\begin{align}
\tilde P_e(\pi) &\approx \hat P_e(\pi) \le \min(\pi,1-\pi,\text{EER})
\end{align}
For bad calibration however, it is possible for $\tilde P_e$ to deteriorate up to $1$ for some values of $\pi$. See figures~\ref{fig:plda} and~\ref{fig:dca_plda}, in the section on experiments below, where we show some examples of both good and bad calibration. We conclude with further Q\&A:
\begin{itemize}[leftmargin=1.5em]
    \item[\textbf{Q:}] Which resources are required for good score calibration?
    \item[\textbf{A:}] The same as for any other machine learning problem: algorithms and data---see the references in this section. Methods vary in their data requirements, from large to small and from supervised to unsupervised.
    \item[\textbf{Q:}] It seems that not only score calibration, but also the user's $\pi$ calibration are too hard. Is it not safer and better to directly threshold the scores, with a threshold set at a fixed false-accept rate?
    \item[\textbf{A:}] Easier, maybe. Safer and better, no. Read on.
\end{itemize}

\section{Generalization to expected cost}
Error-rate can be generalized to risk (expected cost), by assigning the respective costs, $C_\text{miss},C_\text{fa}>0$ to miss and false-accept errors. The Bayes decision threshold generalizes to:
\begin{align}
\label{eq:thetac}
\theta_\pi^c &= \frac{C_\text{fa}(1-\pi)}{C_\text{miss} \pi}
\end{align}
For perfect calibration, $\hat P_e$ generalizes to \emph{optimal expected cost}:
\begin{align}
\hat C_e(\pi) &= C_\text{miss} \piP_\text{miss}(\theta_\pi^c) + C_\text{fa}(1-\pi)P_\text{fa}(\theta_\pi^c)
\end{align}
The trapezium bound becomes~\cite{bosaris}:
\begin{align}
\hat C_e(\pi) \le \min(C_\text{miss} \pi, C_\text{fa}(1-\pi), R^*)
\end{align}
where $R^*$ is the \emph{equal risk}, obtained at a threshold, $\theta^*$, such that:
\begin{align}
R^* &= \CmissP_\text{miss}(\theta^*) = \CfaP_\text{fa}(\theta^*)
\end{align}
In this sense, depending on the ratio $\frac{C_\text{miss}}{C_\text{fa}}$, any point on the ROC can act as upper bound to the optimal expected cost. For practical calibration, actual expected cost, $\tilde C_e$, can be evaluated in a straight-forward generalization of section~\ref{sec:aer}, see~\cite{bosaris}.

\section{Direct score thresholding}
Given a verifier score, $s$, that is not specifically calibrated to function as likelihood-ratio, consider the decision rule:
\begin{align}
\text{decision} &=
\begin{cases}
\text{accept} & \text{if $s \ge \bar\theta$} \\
\text{reject} & \text{if $s \le \bar\theta$}
\end{cases}
\end{align}
One way to proceed, when given a \emph{calibration database} of supervised scores, is to choose the score threshold, $\bar\theta=\bar\theta_\pi^c$, to be approximately equivalent to the optimal likelihood-ratio threshold, $\theta_\pi^c$, by doing:\footnote{$P_\text{miss},\tilde P_\text{miss},\bar P_\text{miss}$ are computed from respectively $r,\tilde r, s$.}
\begin{align}
\label{eq:mindcf}
\bar\theta_\pi^c &= \argmin_{\theta'} \piC_\text{miss}\bar P_\text{miss}(\theta') + (1-\pi)C_\text{fa}\bar P_\text{fa}(\theta')
\end{align}
where $\bar P_\text{miss},\bar P_\text{fa}$ are defined empirically by counting errors when thresholding scores against $\theta'$ in the calibration database. If we assume $\frac{P(s\mid H_1)}{P(s\mid H_2)}$ is monotonic rising, then the optimal expected cost can be computed even from  \emph{uncalibrated} scores:
\begin{align}
\hat C_e(\pi) &= \min_{\theta'} \piC_\text{miss}\bar P_\text{miss}(\theta') + (1-\pi)C_\text{fa}\bar P_\text{fa}(\theta')
\end{align}
This is equivalent to defining a calibration function, $\tilde r = f(s)$, non-parametrically, via the PAV algorithm~\cite{cal}. Given  an independent \emph{test database}, the actual risk at $\bar\theta=\bar\theta_\pi^c$:
\begin{align}
\tilde C_e &= \piC_\text{miss}\bar P_\text{miss}(\bar\theta_\pi^c) + (1-\pi)C_\text{fa}\bar P_\text{fa}(\bar\theta_\pi^c)
\end{align}
gives a more realistic representation of the accuracy at this operating point. Note $\hat P_e$ and $\tilde P_e$ can be obtained from $\hat C_e$ and $\tilde C_e$ by setting $C_\text{miss}=C_\text{fa}=1$.

Another popular solution is to make use of a calibration database containing only $H_2$ scores (which are often easier to collect than $H_1$ scores) and to choose $\bar\theta$ so that some fixed proportion of $H_2$ scores, say $1\%$ of them, are above the threshold, thus fixing (at least on this data) the false-accept rate. If $H_1$ trials are also available, the miss rate at this threshold can be reported as a representation of accuracy.

\emph{Does fixing the false-accept rate thus, make this a safe strategy?} No, the rate is fixed exactly \emph{only} for the dataset that was used to choose the threshold. There is no guarantee on unseen data---neither for this method, nor for any other calibration method. Moreover, this method does not lend itself to reporting accuracy on an independent test database, because on the test data, \emph{both} the miss and false-accept rates could change.

\emph{Surely, this strategy has the advantage that the user does not have to be troubled to provide prior and costs, especially if those could be badly calibrated?} No, ignoring prior and costs, does not cause their essential role in making optimal decisions go away~\cite{Bernardo94,DeGroot70,PTLOS}. Fixing the false-accept rate can be seen as crude way to take the prior and costs into account. Put simply: a bad choice of false-accept rate can have exactly the same effect as a bad choice of $\pi$, $C_\text{miss}$ or $C_\text{fa}$.

In summary, we find no advantages to direct score thresholding, other than its perceived simplicity. At best, it is less flexible than likelihood-ratio calibration, because---unlike the adjustable Bayes threshold---the direct score threshold is fixed. Moreover, the fixed-false-accept method has additional disadvantages: it cannot be tested on independent test data; it obfuscates the role of cost and prior; and in general it does something different from Bayes decisions, so that it does \emph{not} minimize error-rates, nor expected costs.

\section{Experimental demonstration}
Figure~\ref{fig:plda} shows plots\footnote{Code is provided at \url{github.com/bsxfan/PYLLR}.} of the actual Bayes error-rate $\tilde P_e$, for an x-vector speaker verifier, with a standard (generative) PLDA scoring backend, followed by an affine log-likelihood-ratio calibration transform, as implemented in~\cite{DCA_PLDA}. The system was evaluated on three different data sets. On the red and green data sets, the ideal EER bound on $\hat P_e$ is somewhat exceeded, but the prior bound, $\min(\pi,1-\pi)$ is not exceeded. On the blue data set, calibration is very bad, it far exceeds both the EER and the prior bound. The blue data is very clean speech that gives a very low EER (about 0.1\%), but this dataset shift effect causes the calibration to fail.

Figure~\ref{fig:dca_plda} shows a \emph{more complex} backend, DCA-PLDA~\cite{DCA_PLDA}, that was discriminatively trained on a \emph{more diverse} database. It shows much better calibration on all three data sets.\footnote{We have preliminary evidence to suggest the violation of the prior bound on the far right may be due to labelling errors in the VoxCeleb 2 test set.}

\begin{figure}[htb!]
  \centering
  \includegraphics[trim = 0 10 0 10, clip, width=\linewidth]{plda_ber.pdf}
  \caption{PLDA: $\tilde P_e$ evaluated on three data sets, vs respective trapezium bounds, $\min(\pi,1-\pi,\text{EER})$.}
  \label{fig:plda}
\end{figure}
\begin{figure}[htb!]
  \centering
  \includegraphics[trim = 0 10 0 10, clip, width=\linewidth]{dca_plda_ber.pdf}
  \caption{DCA-PLDA: $\tilde P_e$ evaluated on three data sets, vs respective trapezium bounds, $\min(\pi,1-\pi,\text{EER})$.}
  \label{fig:dca_plda}
\end{figure}

\section{Conclusion}
Calibrated scores are more versatile than uncalibrated ones. Bayes decisions minimize error-rates and risk. Ad-hoc decisions don't. The Bayes error-rate and risk are more informative to prospective users than $P_\text{miss}$ and $P_\text{fa}$. Calibration and computing Bayes risk both require some hard work, but the benefits that can be thus obtained can be previewed before investing in this work: the \emph{trapezium upper bound} on the Bayes error-rate (risk) can be computed from the EER (ROC) and these can be computed from uncalibrated scores with standard methods. Although this bound applies only to perfectly calibrated scores, it provides an ideal that can be pursued by practical calibration strategies.

\section{Acknowledgements}
We would like to thank Corne van Biljon of Gendac (Pty) Ltd, for insisting on a simple and direct answer to his question, ``Out of a hundred trials, how many errors would a typical speaker verifier make?''

\bibliographystyle{IEEEtran}