# Generalized Sketches for Streaming Sets
## Appendix A  
(1) **Formula of the gradient \(g(\vec{\lambda})\)**. Each element of \(g(\vec{\lambda})\) is computed as  
\[\frac{\partial\log\mathcal{L}(\vec{x}_{u},\vec{x}_{v})}{\partial \lambda_{u}}=\frac{k_{u,v}^{(6)}}{\lambda_{u}}+\frac{k_{u,v}^{(3)}+k_{u,v}^{ (5)}}{\lambda_{u}-\lambda_{u,v}}-\frac{\sum_{i=1}^{k}x_{u,i}}{k},\]  
\[\frac{\partial\log\mathcal{L}(\vec{x}_{u},\vec{x}_{v})}{\partial \lambda_{v}}=\frac{k_{u,v}^{(5)}}{\lambda_{v}}+\frac{k_{u,v}^{(2)}+k_{u,v}^{ (6)}}{\lambda_{v}-\lambda_{u,v}}-\frac{\sum_{i=1}^{k}x_{v,i}}{k},\]  
\[\frac{\partial\log\mathcal{L}(\vec{x}_{u},\vec{x}_{v})}{\partial \lambda_{u,v}}=\] \[+\frac{\sum_{i=1}^{k}\min(x_{u,i},x_{v,i})}{k}.\]  
(2) **Formula of Hessian matrix \(H(\vec{\lambda})\)**. Each element of \(H(\vec{\lambda})\) is computed as  
\[\frac{\partial^{2}\log\mathcal{L}(\vec{x}_{u},\vec{x}_{v})}{\partial \lambda_{u}^{2}}=-\frac{k_{u,v}^{(6)}}{\lambda_{u}^{2}}-\frac{k_{u,v}^{(3)}+k _{u,v}^{(5)}}{(\lambda_{u}-\lambda_{u,v})^{2}},\]  
\[\frac{\partial^{2}\log\mathcal{L}(\vec{x}_{u},\vec{x}_{v})}{\partial \lambda_{v}^{2}}=-\frac{k_{u,v}^{(5)}}{\lambda_{v}^{2}}-\frac{k_{u,v}^{(2)}+k _{u,v}^{(6)}}{(\lambda_{v}-\lambda_{u,v})^{2}},\]  
\[\frac{\partial^{2}\log\mathcal{L}(\vec{x}_{u},\vec{x}_{v})}{\partial \lambda_{u,v}^{2}}=-\frac{k_{u,v}^{(4)}}{\lambda_{u,v}^{2}}-\frac{k_{u,v}^{(3) }+k_{u,v}^{(5)}}{(\lambda_{u}-\lambda_{u,v})^{2}}-\frac{k_{u,v}^{(2)}+k_{u,v }^{(6)}}{(\lambda_{v}-\lambda_{u,v})^{2}},\]  
\[\frac{\partial^{2}\log\mathcal{L}(\vec{x}_{u},\vec{x}_{v})}{\partial \lambda_{u}\partial\lambda_{v}}=\frac{\partial^{2}\log\mathcal{L}(\vec{x}_{u },\vec{x}_{v})}{\partial\lambda_{v}\partial\lambda_{u}}=0,\]  
\[\frac{\partial^{2}\log\mathcal{L}(\vec{x}_{u},\vec{x}_{v})}{\partial \lambda_{u}\partial\lambda_{u,v}}=\frac{\partial^{2}\log\mathcal{L}(\vec{x}_{u },\vec{x}_{v})}{\partial\lambda_{u,v}\partial\lambda_{u}}=\frac{k_{u,v}^{(3)}+ k_{u,v}^{(5)}}{(\lambda_{u}-\lambda_{u,v})^{2}},\]  
\[\frac{\partial^{2}\log\mathcal{L}(\vec{x}_{u},\vec{x}_{v})}{\partial \lambda_{v}\partial\lambda_{u,v}}=\frac{\partial^{2}\log\mathcal{L}(\vec{x}_{u },\vec{x}_{v})}{\partial\lambda_{u,v}\partial\lambda_{v}}=\frac{k_{u,v}^{(2)}+ k_{u,v}^{(6)}}{(\lambda_{v}-\lambda_{u,v})^{2}}.\]  
(3) **Formula of \(\mathbb{E}(H(\vec{\lambda}))\)**. From Equations (4)-(11), we derive expectations of variables \(k_{u},k_{v},\mathbb{E}(k_{u,v}^{(1)}),\dots,\mathbb{E}(k_{u,v}^{(6)})\) as  
\[\mathbb{E}(k_{u})=ke^{-\frac{\lambda_{u}}{k}},\quad\mathbb{E}(k_{v})=ke^{-\frac {\lambda_{u}}{k}},\]\[\mathbb{E}(k_{u,\
u}^{(1)})=ke^{-\frac{\lambda_{u}+\lambda_{v}-\lambda_{u \
u}}{k}},\] \[\mathbb{E}(k_{u,\
u}^{(2)})=k(e^{-\frac{\lambda_{u}}{k}}-e^{-\frac{ \lambda_{u}+\lambda_{v}-\lambda_{u\
u}}{k}}),\] \[\mathbb{E}(k_{u,\
u}^{(3)})=k(e^{-\frac{\lambda_{v}}{k}}-e^{-\frac{ \lambda_{u}+\lambda_{v}-\lambda_{u\
u}}{k}}),\] \[\mathbb{E}(k_{u,\
u}^{(4)})=\frac{k\lambda_{u,\
u}}{\lambda_{u}+ \lambda_{v}-\lambda_{u,\
u}}(1-e^{-\frac{\lambda_{u}+\lambda_{v}-\lambda_{u\
u }}{k}}),\] \[\mathbb{E}(k_{u,\
u}^{(5)})=\frac{k(\lambda_{u}-\lambda_{u,\
u})} {\lambda_{u}+\lambda_{v}-\lambda_{u,\
u}}(1-e^{-\frac{\lambda_{u}+\lambda_{v}- \lambda_{u\
u}}{k}})-\mathbb{E}(k_{u,\
u}^{(3)}),\] \[\mathbb{E}(k_{u,\
u}^{(6)})=\frac{k(\lambda_{v}-\lambda_{u,\
u})} {\lambda_{u}+\lambda_{v}-\lambda_{u,\
u}}(1-e^{-\frac{\lambda_{u}+\lambda_{v}- \lambda_{u\
u}}{k}})-\mathbb{E}(k_{u,\
u}^{(2)}).\]  
Based the above equations and the formula of \(H(\vec{\lambda})\), we easily obtain the formula of each entry of matrix \(\mathbb{E}(H(\vec{\lambda}))\).