diff --git a/CFA/CFA Rates and Return.md b/CFA/CFA Rates and Return.md index 545789e..7419181 100644 --- a/CFA/CFA Rates and Return.md +++ b/CFA/CFA Rates and Return.md @@ -4,7 +4,9 @@ documentclass: "ctexart" classoption: "UTF8" --- # CFA Rates and Return + ## INTEREST RATES, PRESENT VALUE, AND FUTURE VALUE + 1. interpret interest rates as required rates of return, discount rates, or opportunity costs 解释利率为所需的回报率,折现率或机会成本 1. interest rate = real risk-free rate + premium @@ -16,8 +18,11 @@ classoption: "UTF8" 不同的复利频率 1. calculate and interpret the effective annual rate (EAR) and annual interest rate (APR) 计算和解释有效年利率(EAR)和年利率(APR) + ## Note + ### Interest Rates + - Real Risk-free rate: the time preferences of individuals for current versus future real consumption. 不考虑通货膨胀的情况下的无风险利率, 通常是美国国债利率。代表个人对现在和未来消费的偏好 - Inflation premium: The inflation premium compensates investors for the expected erosion of purchasing power of a bond’s future cash flows due to inflation. @@ -34,23 +39,32 @@ governmental short-term debt (T-bills) is often used as a proxy for the nominal 美国T票的流动性溢价为零 - Maturity risk premium: The maturity premium compensates investors for the increased sensitivity of the market value of debt to a change in market interest rates as maturity is extended, in general (holding all else equal). The difference between the interest rate on longer-maturity, liquid Treasury debt and that on short-term Treasury debt reflects a positive maturity premium for the longer-term debt (and possibly different inflation premiums as well). 到期风险溢价:到期风险溢价补偿投资者对债务市场价值对市场利率变化的敏感性,因为到期日延长,一般来说(其他条件不变)。较长期限的流动性美国国债利率与短期美国国债利率之间的差异反映了较长期债务的正到期溢价(以及可能的不同通货膨胀溢价)。 + ### FUTURE VALUE OF A SINGLE CASH FLOW + - Future value (FV) - Present value (PV) - Number of periods (n) - Stated annual interest rate 是年利率,不是实际利率 -lump sum (一次性支付): 仍然是 $FV = PV(1+r)^n$ +lump sum (一次性支付): 仍然是$FV = PV(1+r)^n$ Pension fund: 养老金 + $$ FV = PV(1+r)^n $$ + ### NON-ANNUAL COMPOUNDING (FUTURE VALUE) + LO: calculate the solution for time value of money problems with different frequencies of compounding + ### Annuity (年金) + - Ordinary annuity (普通年金): payments occur at the end of each period - Annuity due (年金): payments occur at the beginning of each period - Perpetuity (永续年金): an annuity with an infinite life + ### Mortgage (抵押贷款) + - Down payment (首付) - We use the equation from annuity to calculate the monthly payment @@ -75,9 +89,9 @@ $$ $$ R = \frac{P_1 - P_0 + I_1}{P_0} $$ -- $P_0$ is the initial price -- $P_1$ is the final price -- $I_1$ is the income received during the period +-$P_0$is the initial price +-$P_1$is the final price +-$I_1$is the income received during the period ### Arithmetic or Mean Return $$ \bar{R_i} = \frac{1}{n} \sum_{t=1}^n R_{it} @@ -100,9 +114,9 @@ $$ $$ > Steps: > -> 1. Suppose the return $r$ (see it as interest rate) is unknown. -> 2. Calculate the present value of all cash flows using the unknown return $r$. -> 3. Solve for $r$. +> 1. Suppose the return$r$(see it as interest rate) is unknown. +> 2. Calculate the present value of all cash flows using the unknown return$r$. +> 3. Solve for$r$. #### Time-Weighted Rate of Return $$ \prod_{t=1}^n (1 + r_t) = \frac{P_n}{P_0} @@ -157,8 +171,8 @@ $$ $$ R_L = \frac{\text{Portfolio Return}}{\text{Investor's Equity}} = \frac{R_P(V_E + V_B)-V_B r_D}{V_E} = R_P + \frac{V_B}{V_E}(R_P - r_D) $$ -- $R_L$: leverage return -- $R_P$: portfolio return 投资组合回报率 -- $V_E$: investor's equity 投资者的股权 -- $V_B$: borrowed funds 借来的资金 -- $r_D$: cost of borrowed funds 借来的资金的成本 +-$R_L$: leverage return +-$R_P$: portfolio return 投资组合回报率 +-$V_E$: investor's equity 投资者的股权 +-$V_B$: borrowed funds 借来的资金 +-$r_D$: cost of borrowed funds 借来的资金的成本 diff --git a/CFA/Corporate Issuers/Breakeven_Point.md b/CFA/Corporate Issuers/Breakeven_Point.md index fa37e20..9bd745b 100644 --- a/CFA/Corporate Issuers/Breakeven_Point.md +++ b/CFA/Corporate Issuers/Breakeven_Point.md @@ -4,16 +4,20 @@ documentclass: "ctexart" classoption: "UTF8" --- # Breakeven point -## $Q_{\text{BE}}$ (Breakeven point) + +## $Q_{\text{BE}}$(Breakeven point) + NI 等于 0 时的销量。 $$ Q_{\text{BE}} = \frac{F + C}{P - V} $$ -- $F$ = 固定运营成本 -- $C$ = 固定财务成本 -- $P$ = 单位价格 -- $V$ = 单位变动成本 + +-$F$= 固定运营成本 +-$C$= 固定财务成本 +-$P$= 单位价格 +-$V$= 单位变动成本 Operating breakeven point + $$ Q_{\text{OBE}} = \frac{F}{P - V} $$ diff --git a/CFA/Corporate Issuers/Capital_Structure.md b/CFA/Corporate Issuers/Capital_Structure.md index 1f917c1..683dc2c 100644 --- a/CFA/Corporate Issuers/Capital_Structure.md +++ b/CFA/Corporate Issuers/Capital_Structure.md @@ -4,21 +4,29 @@ documentclass: "ctexart" classoption: "UTF8" --- # Capital Structure + ## 周期 + ## MM model (Modigliani-Miller) + ### Assumptions + - Homogeneous expectations 一致的预期 - Perfect capital markets 完美的资本市场 (no taxes, no transaction costs, no bankruptcy costs, everyone has the same information) - 借款按照 risk-free rate 借 - No agency costs 代理成本 - Indepedent Decision 融资和投资决策是独立的 + ### 四种情况 + | | 无税 | 有税 | | --- | --- | --- | | I | 1 | 3 | | II | 2 | 4 | + 1. 无论公司的资本结构如何,价值都是一样的 2. 价值也是一样的 + $$ V_L = V_U $$ @@ -28,31 +36,45 @@ $$ $$ r_e E + r_d D = r_0 (E + D) $$ -3. $V_L = V_U + t D$ -4. $r_e = r_0 + \frac{D}{E} \times (r_0 - r_d) \times (1 - t)$ + +3.$V_L = V_U + t D$ +4.$r_e = r_0 + \frac{D}{E} \times (r_0 - r_d) \times (1 - t)$ + $$ V_L = V_U + t D - PV (financial distress costs) $$ 3 / 4 负债的成本会比权益的成本低 + ### reflection on MM model + - Direct cost - bankruptcy cost - Indirect cost - agency cost + ## Optimal Capital Structure + $$ V_L = V_U + t D - PV $$ + ### Target Capital Structure -达到最优的资本结构时 ($V_L$ 最大) + +达到最优的资本结构时 ($V_L$最大) + ### Methods to estimate the target capital structure + - Market value weights - Examine trends - Peer group comparison + ## Factors that influence the capital structure decision + - Financing Capital Investment 机会转瞬即逝 - Market conditions 股价之类的 - Information asymmetry 信息不对称 - Pecking order theory 融资的顺序 + ## Agency Costs + - agency 和 principal 之间的冲突 diff --git a/CFA/Corporate Issuers/Cost_of_Capital.md b/CFA/Corporate Issuers/Cost_of_Capital.md index a806d34..aa1e428 100644 --- a/CFA/Corporate Issuers/Cost_of_Capital.md +++ b/CFA/Corporate Issuers/Cost_of_Capital.md @@ -4,25 +4,31 @@ documentclass: "ctexart" classoption: "UTF8" --- # Cost of Capital + 1. WACC (Weighted Average Cost of Capital) 2. Cost of Different Sources of Capital 3. Estimating Beta 4. Flotation Costs + ## WACC (Weighted Average Cost of Capital) + $$ WACC = \frac{E}{V} \times r_e + \frac{D}{V} \times r_d \times (1 - T_c) + \frac{P}{V} \times r_p $$ 这里每一项都是边际值 -- $E$: market value of equity -- $D$: market value of debt -- $V$: total market value of equity and debt -- $r_e$: cost of equity -- $r_d$: cost of debt -- $T_c$: corporate tax rate -- $P$: market value of preferred stock -- $r_p$: cost of preferred stock + +-$E$: market value of equity +-$D$: market value of debt +-$V$: total market value of equity and debt +-$r_e$: cost of equity +-$r_d$: cost of debt +-$T_c$: corporate tax rate +-$P$: market value of preferred stock +-$r_p$: cost of preferred stock market value + ## Cost of Different Sources of Capital + - Debt - YTM (yield to maturity) - Debt rating 利用债券评级 @@ -31,45 +37,65 @@ $$ - Common stock - CAPM - Bond yield plus risk premium + ### YTM (yield to maturity) 折现率 + $$ P_0 = \frac{PMT}{1 + YTM} + \frac{PMT}{(1 + YTM)^2} + \cdots + \frac{PMT + FV}{(1 + YTM)^n} $$ -- $P_0$: current price -- $PMT$: payment -- $FV$: face value -- $n$: number of periods + +-$P_0$: current price +-$PMT$: payment +-$FV$: face value +-$n$: number of periods + ### Preferred Stock + $$ r_p = \frac{D}{P} $$ -- $D$: dividend -- $P$: price market value + +-$D$: dividend +-$P$: price market value + ### CAPM (Capital Asset Pricing Model) + $$ E(R_i) = R_f + \beta_i \times (E(R_m) - R_f) $$ -- $E(R_i)$: expected return -- $R_f$: risk-free rate -- $\beta_i$: the return sensitivity of stock $i$ to changes in the market return: 股票的市场敏感性 -- $E(R_m)$: expected return of the market + +-$E(R_i)$: expected return +-$R_f$: risk-free rate +-$\beta_i$: the return sensitivity of stock$i$to changes in the market return: 股票的市场敏感性 +-$E(R_m)$: expected return of the market + ### Bond yield plus risk premium + $$ r_e = r_d + \text{risk premium} $$ -- $r_d$: cost of debt 税前 + +-$r_d$: cost of debt 税前 + ## Estimating Beta + ### Unpublished or thinly traded companies + Two components + - 财务风险 - 属性风险 找到一个相似的公司 + $$ \beta_U = \beta_E \times \frac{1}{1 + (1 - t) \frac{D}{E}} \\ \beta_E = \beta_U \times (1 + (1 - t) \frac{D}{E}) $$ -- $\beta_U$ : unlevered beta -- $\beta_E$ : levered beta + +-$\beta_U$: unlevered beta +-$\beta_E$: levered beta + ## Flotation Costs + - First way: incorporate the flotation costs into the cost of capital, 利用高登模型 - Second way: deduct the flotation costs from the initial cash flow, 利用调整后的现金流 diff --git a/CFA/Corporate Issuers/Financial Risk and Financial Leverage.md b/CFA/Corporate Issuers/Financial Risk and Financial Leverage.md index e6348e1..19f1385 100644 --- a/CFA/Corporate Issuers/Financial Risk and Financial Leverage.md +++ b/CFA/Corporate Issuers/Financial Risk and Financial Leverage.md @@ -4,10 +4,15 @@ documentclass: "ctexart" classoption: "UTF8" --- # Financial Risk and Financial Leverage + ## Financial Risk + 债的利息 + ### DFL (Degree of Financial Leverage) + $$ \textrm{DFL} = \frac{\text{percentage change in NI}}{\text{percentage change in EBIT}} = \frac{\frac{\Delta \text{NI}}{\text{NI}}}{\frac{\Delta \text{EBIT}}{\text{EBIT}}}= \frac{Q(P-V) - F}{Q(P-V) - F - C} $$ -- $C$ = 固定的财务成本 + +-$C$= 固定的财务成本 diff --git a/CFA/Corporate Issuers/Operating Risk and Operating Leverage.md b/CFA/Corporate Issuers/Operating Risk and Operating Leverage.md index 3fdb7a8..4e6e914 100644 --- a/CFA/Corporate Issuers/Operating Risk and Operating Leverage.md +++ b/CFA/Corporate Issuers/Operating Risk and Operating Leverage.md @@ -4,22 +4,30 @@ documentclass: "ctexart" classoption: "UTF8" --- # Operating Risk and Operating Leverage + ## Operating Risk + - 如果有固定成本,那么就有风险 - 固定成本/可变成本越大,风险越大 + ## Operating Leverage + DOL (Degree of Operating Leverage) + ### 定义式 + $$ DOL = \frac{\% \Delta EBIT}{\% \Delta Sales} $$ 单位销量的变化导致Operating Income的变化 + ### 计算式 + $$ DOL = \frac{Q(P - V)}{Q(P - V) - F} = \frac{sale - \text{TVC}}{sale - \text{TVC} - F} $$ -- $Q$: quantity -- $P$: price per unit -- $V$: variable cost per unit -- $F$: fixed cost -- $\text{TVC}$: total variable cost +-$Q$: quantity +-$P$: price per unit +-$V$: variable cost per unit +-$F$: fixed cost +-$\text{TVC}$: total variable cost diff --git a/CFA/Equity/Positions_and_short_selling.md b/CFA/Equity/Positions_and_short_selling.md index 1ec93f5..34a6cf5 100644 --- a/CFA/Equity/Positions_and_short_selling.md +++ b/CFA/Equity/Positions_and_short_selling.md @@ -4,17 +4,22 @@ documentclass: "ctexart" classoption: "UTF8" --- # Positions and short selling + - Long position: 多头头寸 - Short position: 空头头寸 - Leverage position: 杠杆头寸 + ## Short position + - 两笔 - Borrowing cost: 借款成本 - Interest from the short sale proceeds: 空头卖出所得利息 - All dividends and interest on the shorted stock are paid to the lender of the stock. - Short rebate rate: 空头回购利率 - The rate at which the short seller can invest the proceeds from the short sale. + ## Leveraged position + - Buy on margin: 保证金交易 - The investor buy securities by borrowing some of the purchase price from a brokerage firm. - The borrowed money is the margin loan. Buyer's equity is the portion of the purchase price that is not borrowed. @@ -28,13 +33,15 @@ classoption: "UTF8" - The minimum amount of equity that the investors must maintain in the margin account. - Margin call: 保证金追缴 - A demand by the brokerage firm for the investor to deposit additional funds or securities to bring the margin account up to the minimum maintenance margin requirement. + ### Price triggering the margin call + $$ P_c = P_0 \frac{1 - IM}{1 - MM} $$ 假设:先亏自己的钱,再亏借来的钱。 Margin call 条件: 自有资金占比小于$MM$. -- $P_c$: Price triggering the margin call -- $P_0$: Initial price of the stock -- $IM$: Initial margin requirement -- $MM$: Maintenance margin requirement +-$P_c$: Price triggering the margin call +-$P_0$: Initial price of the stock +-$IM$: Initial margin requirement +-$MM$: Maintenance margin requirement diff --git "a/CFA/\350\264\242\346\212\245/Cash-Flow/cfi_and_cff.md" "b/CFA/\350\264\242\346\212\245/Cash-Flow/cfi_and_cff.md" index 4a8869a..2cc25a7 100644 --- "a/CFA/\350\264\242\346\212\245/Cash-Flow/cfi_and_cff.md" +++ "b/CFA/\350\264\242\346\212\245/Cash-Flow/cfi_and_cff.md" @@ -4,16 +4,20 @@ documentclass: "ctexart" classoption: "UTF8" --- # CFI & CFF + ## CFI + | B | A | S | E | | -------------- | -------- | ------------------------------- | -------------- | -| $\text{NCA}_b$ | purchase | disposal, dep, impairment固定资产减值 | $\text{NCA}_e$ | +|$\text{NCA}_b$| purchase | disposal, dep, impairment固定资产减值 |$\text{NCA}_e$| NCA: Non-current Assets Book value = carrying value = 账面值 累计折旧中要减去被处置资产的折旧 + ## CFF + - Long-term debt - Dividend paid | B | A | S | E | | -------------- | ---------- | ----------------- | -------------- | -| $\text{R/E}_b$ | Net Income | Dividend Declared | $\text{R/E}_e$ | +|$\text{R/E}_b$| Net Income | Dividend Declared |$\text{R/E}_e$| diff --git "a/CFA/\350\264\242\346\212\245/Income_Statement.md" "b/CFA/\350\264\242\346\212\245/Income_Statement.md" index 51040a8..8f84dc1 100644 --- "a/CFA/\350\264\242\346\212\245/Income_Statement.md" +++ "b/CFA/\350\264\242\346\212\245/Income_Statement.md" @@ -4,6 +4,7 @@ documentclass: "ctexart" classoption: "UTF8" --- # Income Statement + - [Income Statement](#income-statement) - [Relationship with other financial statements](#relationship-with-other-financial-statements) - [格式](#格式) @@ -12,12 +13,17 @@ classoption: "UTF8" - [Net Income](#net-income) - [The Line](#the-line) - [Recognizing Revenue](#recognizing-revenue) + ## Relationship with other financial statements + SCI = IS + OCI + - SCI: Statement of Comprehensive Income - IS: Income Statement - OCI: Other Comprehensive Income + ## 格式 + - Rev: Revenue (Net Revenue = Revenue - Adjustments(三包费用等)) - COGS: Cost of Goods Sold - Gross Profit = Rev - COGS @@ -31,10 +37,13 @@ SCI = IS + OCI - Profit Before Tax = Operating Profit - Interest Expense - Tax Expense - Profit After Tax = Profit Before Tax - Tax Expense = Net Income + ## Expense + - Grouping - By nature - By function + >Remark: **Distinguish between by nature and by function** > >For example, a company has 2 buildings, one is used for production, the other is used for administration. The company has 2 options to record the depreciation expense: @@ -44,12 +53,17 @@ SCI = IS + OCI > - By function: (the cost of sales method) > - Production: included in COGS > - Administration: included in Period Cost +> ## Gain/Loss + - Gain/Loss on sale of PPE(PPE: Property, Plant and Equipment, 不动产、厂房设备等) + > Remark: PBIT includes non-recurring gains and losses, while operating income does not. +> ## Net Income - -- $ \text{Net Income} = \text{Revenue} - \text{ordinary expenses} + \text{Gains} - \text{Losses} + \text{other income} - \text{other expenses} $ + +-$\text{Net Income} = \text{Revenue} - \text{ordinary expenses} + \text{Gains} - \text{Losses} + \text{other income} - \text{other expenses}$ + > Multiple-step income statement vs single-step income statement > > - multiple-step income statement @@ -60,11 +74,16 @@ SCI = IS + OCI > - 一步到位,直接算出 Net Income > - 适用于简单的公司 > - 没有 Gross Profit, Operating Income 等概念 +> ## The Line + Net Income from Continuing Operations + - Above the line: tax is reported separately - Below the line: tax is included in the calculation of net income + ## Recognizing Revenue + - Under the accrual basis of accounting, revenue is recognized when: - the earnings process is complete or virtually complete - there is reasonable certainty as to the collectibility of the asset to be received (cash or receivable) diff --git a/Canada/Response.md b/Canada/Response.md index badc124..a2120f0 100644 --- a/Canada/Response.md +++ b/Canada/Response.md @@ -4,26 +4,30 @@ documentclass: "ctexart" classoption: "UTF8" --- # Response + ## Comments from the reviewer + 评审员指出,在回应2中,作者提到“实际上,无论是细胞表面还是凸包,在计算机上我们处理的都是它们的离散点。”评审员接着解释,有限点集的凸包是多面体(有界多面体),其边界是非光滑的。此外,手稿中写道:“凸包为进一步分析提供了两个重要信息:包含整个细胞表面的最小凸多面体...”,因此在这一点上作者和评审员似乎是一致的。 作者在回应中继续说:“换句话说,我们可以理解这些离散点是其真实连续光滑函数上的采样值。”评审员提出假设,将M和N(细胞表面和其凸包的真实边界)视为光滑流形。然后,他们将计算机上找到的离散点的凸包边界称为Q。这不是一个光滑流形。因此,即使可以将第3.1、3.3和3.4节的理论直接应用于M和N,但不能应用于Q。换句话说,Q只是N的多面体近似。任何近似都伴随着近似误差和其他在手稿中被忽视的问题。评审员建议在手稿中添加有关这个问题的评论。 此外,评审员指出,先前章节的理论和第3.6节中描述的实现之间存在明显差距。顺便说一下,第3.6节非常简短,且在算法1的子程序中隐藏了许多重要的实现细节。也许这就是为什么作者不得不在回应3和4中向评审员解释这些细节。但这些细节应该包含在手稿中! + ## Response to the comments + 谢谢评审员的建议!的确,在进行实际计算时候,细胞表面是离散点构成的三角网格,而凸包是由这些离散点构成的多面体,所以理论分析部分不能直接用于实际计算。我们决定通过remark 3.1来解释这个问题,因为虽然实际参与计算的细胞表面和凸包都不是光滑流形,但是他们却是真实的细胞表面流形和凸包流形的近似。再根据映射的连续性,我们可以得到实际计算中的细胞表面和凸包的近似误差。我们在remark 3.1中给出了这个误差的上界。 - - -Denote the cateogry of $3$-dimensional manifolds as $\mathcal{M}$, and the convex-hull morphism $f$ is defined as + + +Denote the cateogry of$3$-dimensional manifolds as$\mathcal{M}$, and the convex-hull morphism$f$is defined as $$ \begin{aligned} f: \mathcal{M} &\rightarrow \mathcal{M} \\ M &\mapsto N \end{aligned} -$$ where $N$ is the convex hull of $M$. Then $f$ is a smooth morphism/diffeomorphism. -Consider the discrete approximation of any $M \in \mathcal{M}$, denoted as $P$. Regardless how $d$ is concretely define, as far as $d$ is a distance on $\mathcal{M}$, then given a manifold $M$, $\forall \epsilon > 0$, there exists a $g_\theta$ such that $d(M, g_\theta(M)) < \epsilon$, where $g_\theta$ is the discrete approximation and $\theta$ is the parameter of the discrete approximation. -Now suppose that the surface of a cell is a smooth manifold $M$ and its convex hull is a smooth manifold $N$. Let $P$ be the discrete surface of the cell and $Q$ be the discrete convex hull of the cell. -$\forall \epsilon_1 > 0$, $\exists \theta > 0$, such that $d(M, P) < \epsilon_1$, where $P = g_\theta(M)$ and $g_\theta$ is the discrete approximation of $M$. -And denote the discrete approximation of $N$ as $Q' = g_{\theta}(N)$, then also for the given $\epsilon_2 > 0$, there exists an $\delta > 0$, such that $d(N, Q') < \epsilon_2$. As far as $\epsilon_1 < \delta$, then $d(M, P) < \epsilon_1 < \delta$, and $d(N, Q') < \epsilon_2$. Then we have $d(P, Q') < \epsilon_2$. -And for the other way, since $Q = f(P)$, then $d(Q, Q') < \epsilon_3$ +$$where$N$is the convex hull of$M$. Then$f$is a smooth morphism/diffeomorphism. +Consider the discrete approximation of any$M \in \mathcal{M}$, denoted as$P$. Regardless how$d$is concretely define, as far as$d$is a distance on$\mathcal{M}$, then given a manifold$M$,$\forall \epsilon > 0$, there exists a$g_\theta$such that$d(M, g_\theta(M)) < \epsilon$, where$g_\theta$is the discrete approximation and$\theta$is the parameter of the discrete approximation. +Now suppose that the surface of a cell is a smooth manifold$M$and its convex hull is a smooth manifold$N$. Let$P$be the discrete surface of the cell and$Q$be the discrete convex hull of the cell. +$\forall \epsilon_1 > 0$,$\exists \theta > 0$, such that$d(M, P) < \epsilon_1$, where$P = g_\theta(M)$and$g_\theta$is the discrete approximation of$M$. +And denote the discrete approximation of$N$as$Q' = g_{\theta}(N)$, then also for the given$\epsilon_2 > 0$, there exists an$\delta > 0$, such that$d(N, Q') < \epsilon_2$. As far as$\epsilon_1 < \delta$, then$d(M, P) < \epsilon_1 < \delta$, and$d(N, Q') < \epsilon_2$. Then we have$d(P, Q') < \epsilon_2$. +And for the other way, since$Q = f(P)$, then$d(Q, Q') < \epsilon_3$ $$ \begin{aligned} diff --git a/CityU/Yan's first idea.md b/CityU/Yan's first idea.md index 51d58a1..6732682 100644 --- a/CityU/Yan's first idea.md +++ b/CityU/Yan's first idea.md @@ -4,13 +4,14 @@ documentclass: "ctexart" classoption: "UTF8" --- # Steps to find co-clusters in a compatibility matrix -> Assume the compatibility matrix is $A_{ij}$. > -> Step 1: Compute horizontal projection $P_i(i) = \sum_{j} A_{ij}$ +> Assume the compatibility matrix is$A_{ij}$. > -> Step 2: Find $i_{max}$ for which $P_i(i_{max})$ is maximum among all i values +> Step 1: Compute horizontal projection$P_i(i) = \sum_{j} A_{ij}$ > -> Step 3: Form $A_1(i, j) = |A_{ij} - A_{i_{max}j}|$ +> Step 2: Find$i_{max}$for which $P_i(i_{max})$is maximum among all i values +> +> Step 3: Form$A_1(i, j) = |A_{ij} - A_{i_{max}j}|$ > > Step 4: Compute horizontal projection P_{1i}(i) = Sum_{all j} A1(i, j) > diff --git a/Excalidraw/Scripts/Downloaded/Add Link to New Page and Open.md b/Excalidraw/Scripts/Downloaded/Add Link to New Page and Open.md index 5dbaac7..4097bc4 100644 --- a/Excalidraw/Scripts/Downloaded/Add Link to New Page and Open.md +++ b/Excalidraw/Scripts/Downloaded/Add Link to New Page and Open.md @@ -6,6 +6,7 @@ classoption: "UTF8" /* ![](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-add-link-to-new-page-and-pen.jpg) Prompts for filename. Offers option to create and open a new Markdown or Excalidraw document. Adds link pointing to the new file, to the selected objects in the drawing. You can control in settings to open the file in the current active pane or an adjacent pane. + ```javascript */ if(!ea.verifyMinimumPluginVersion || !ea.verifyMinimumPluginVersion("1.6.1")) { @@ -18,7 +19,7 @@ if(!settings["Open link in active pane"]) { "Open link in active pane": { value: false, description: "Open the link in the current active pane (on) or a new pane (off)." - }, + }, ...settings }; ea.setScriptSettings(settings); @@ -36,12 +37,12 @@ let fileType = ""; const filename = await utils.inputPrompt ( "Filename for new document", "", - `${prefix} - ${timestamp}`, + `${prefix} -${timestamp}`, [ { caption: "Markdown", action: ()=>{fileType="md";return;} - }, + }, { caption: "Excalidraw", action: ()=>{fileType="ex";return;} @@ -63,7 +64,7 @@ ea.style.strokeWidth = 2; ea.style.roughness = 0; if(elements.length===1 && elements[0].type !== "text") { ea.copyViewElementsToEAforEditing(elements); - ea.getElements()[0].link = link; + ea.getElements()[0].link = link; } else { const b = ea.getBoundingBox(elements); const id = ea.addEllipse(b.topX+b.width-5, b.topY, 5, 5); @@ -74,7 +75,7 @@ if(elements.length===1 && elements[0].type !== "text") { await ea.addElementsToView(false,true,true); ea.selectElementsInView(ea.getElements()); if(openInCurrentPane) { - app.workspace.openLinkText(file.path,ea.targetView.file.path,false); + app.workspace.openLinkText(file.path,ea.targetView.file.path,false); return; } ea.openFileInNewOrAdjacentLeaf(file); diff --git "a/Game/\351\222\242\351\223\201\351\233\204\345\277\203\345\205\254\345\274\217.md" "b/Game/\351\222\242\351\223\201\351\233\204\345\277\203\345\205\254\345\274\217.md" index d3c9dce..98f69df 100644 --- "a/Game/\351\222\242\351\223\201\351\233\204\345\277\203\345\205\254\345\274\217.md" +++ "b/Game/\351\222\242\351\223\201\351\233\204\345\277\203\345\205\254\345\274\217.md" @@ -4,7 +4,9 @@ documentclass: "ctexart" classoption: "UTF8" --- # 所有公式 + ## 空战 + 机动 agility 速度 velocity 伤害 damage @@ -16,7 +18,7 @@ r_a&=(\frac{v_a}{v_d}-1)\times 0.6, \\ r_d&=(\frac{a_d}{a_a}-1)\times 0.3 \end{aligned} $$ -$v_a$为攻击方速度, $v_d$为防御方速度, $a_d$为防御方机动, $a_a$为攻击方机动, $r_a$为攻击方伤害增加, $r_d$为防御方伤害减免 +$v_a$为攻击方速度,$v_d$为防御方速度,$a_d$为防御方机动,$a_a$为攻击方机动,$r_a$为攻击方伤害增加,$r_d$为防御方伤害减免 只有速度高于对方时才会造成伤害增加, 机动高于对方时才会造成伤害减免. 最大机动比值为4, 最大速度比值为3.5 > 机动带来的最大伤害减免为0.9, 速度带来的最大伤害增加为1.5 @@ -25,13 +27,15 @@ $$ % 攻击基础伤害 = 攻击方数量 \times 对空攻击 \times 0.2 \\ d_b &= n_a \times d_a \times 0.2 \\ d_{ab} &= 2.5\% \times 0.01 \times v_a / 800 \\ -D &= 0.01 \times d_b \times (1 - r_d + d_{ab} + r_a) / d_d +D &= 0.01 \times d_b \times (1 - r_d + d_{ab} + r_a) / d_d \end{aligned} $$ -$d_b$为攻击方基础伤害, $n_a$为攻击方数量, $d_a$为攻击方对空攻击, $d_{ab}$为攻击方对空绝对速度加成, $d_d$为防御方对空防御, $D$为伤害. +$d_b$为攻击方基础伤害,$n_a$为攻击方数量,$d_a$为攻击方对空攻击,$d_{ab}$为攻击方对空绝对速度加成,$d_d$为防御方对空防御,$D$为伤害. + ## 防空减免 + $$ aa_d = \frac{0.7y}{y+112} $$ -$y$为防空值, $aa_d$为防空减免 -> $25$ 点防空就可以抵消突破防御和速度debuff, $10.8$ 可以达到 $75\%$ 的舔地机减免上限. \ No newline at end of file +$y$为防空值,$aa_d$为防空减免 +>$25$点防空就可以抵消突破防御和速度debuff,$10.8$可以达到$75\%$的舔地机减免上限. diff --git a/HPC/GPG on hpc.md b/HPC/GPG on hpc.md index f71ba88..393ae71 100644 --- a/HPC/GPG on hpc.md +++ b/HPC/GPG on hpc.md @@ -4,12 +4,16 @@ documentclass: "ctexart" classoption: "UTF8" --- # GPG on hpc + ## loopback + - `echo allow-loopback-pinentry >> ~/.gnupg/gpg-agent.conf` - input passphrase in `~/.___` -- `echo -n "#\!/usr/bin/bash \ngpg --pinentry-mode loopback --batch --yes --passphrase-fd 1 --passphrase-file ~/.___ $@" >> ~/.gpg-pinentry-loopback` +- `echo -n "#\!/usr/bin/bash \ngpg --pinentry-mode loopback --batch --yes --passphrase-fd 1 --passphrase-file ~/.___$@" >> ~/.gpg-pinentry-loopback` - `chmod +x ~/.gpg-pinentry-loopback` -- `git config --global gpg.program $HOME/.gpg-pinentry-loopback` +- `git config --global gpg.program$HOME/.gpg-pinentry-loopback` - success in vscode + ## Time Cache + - `echo -n "default-cache-ttl 34560000\n max-cache-ttl 34560000" >> ~/.gnupg/gpg-agent.conf` diff --git a/HPC/index.md b/HPC/index.md index 29b1204..1a18c68 100644 --- a/HPC/index.md +++ b/HPC/index.md @@ -4,72 +4,80 @@ documentclass: "ctexart" classoption: "UTF8" --- # User Guide for Accessing Central HPC Cluster (CityU Burgundy) --- 访问中央HPC集群用户指南(CityU Burgundy) + # User Guide for Accessing Central HPC Cluster (CityU Burgundy) + 访问中央HPC集群用户指南(CityU Burgundy) -* [Access to the System + +* [Access to the System 访问系统](#access) -* [Job Submission  工作提交](#job) -* [General Guidelines for Job Submission +* [Job Submission  工作提交](#job) +* [General Guidelines for Job Submission 作业提交的一般准则](#guidelines) -* [Disk Storage and Quota +* [Disk Storage and Quota 磁盘存储和配额](#diskstorage) -* [Software Stacks 软件堆栈](#software) +* [Software Stacks 软件堆栈](#software) + ## Access to the System + 访问系统 -* There is no graphical user interface for Burgundy, users must logon the system with Secure Shell (SSH), and “x forwarding with SSH” is supported with -Y option. + +* There is no graphical user interface for Burgundy, users must logon the system with Secure Shell (SSH), and “x forwarding with SSH” is supported with -Y option. Burgundy 没有图形用户界面,用户必须使用 Secure Shell (SSH) 登录系统,并且 -Y 选项支持“使用 SSH 进行 x 转发”。 -* Use PuTTY (on Window) or Terminal (Linux or Mac) to access Burgundy. +* Use PuTTY (on Window) or Terminal (Linux or Mac) to access Burgundy. 使用 PuTTY(在 Window 上)或终端(Linux 或 Mac)访问 Burgundy。 -* Users should login to the system with CityU EID and Password. At the SSH terminal, type: +* Users should login to the system with CityU EID and Password. At the SSH terminal, type: 用户应使用 CityU EID 和密码登录系统。在 SSH 终端输入: > ssh @burgundy.hpc.cityu.edu.hk > ssh @burgundy.hpc.cityu.edu.hk - > + > > OR - > + > > ssh @144.214.138.99 > ssh @144.214.138.99 -* PuTTY can be downloaded from [https://www.putty.org/](https://www.putty.org/) - PuTTY 可以从 https://www.putty.org/ 下载 +* PuTTY can be downloaded from [https://www.putty.org/](https://www.putty.org/) + PuTTY 可以从 下载 ![](1691122292-9f48917200673547e9e985c07557671f.jpg) + ## Job Submission 工作提交 -1. General Policy Statement 一般政策声明 + +1. General Policy Statement 一般政策声明 _The current scheduling policy and resource restrictions, including partition, quota, and charging scheme, are temporary. The final design will be discussed, decided, and regularly reviewed by the User Committee. 当前的调度策略和资源限制,包括分区、配额和计费方案,都是临时的。最终设计将由用户委员会讨论、决定并定期审查。_ -2. Partitions and Priority  分区和优先级 - 1. Job Partitions  作业分区 - * 7 CPU/GPU partitions are currently available for all users +2. Partitions and Priority  分区和优先级 + 1. Job Partitions  作业分区 + * 7 CPU/GPU partitions are currently available for all users 目前7个CPU/GPU分区可供所有用户使用 ![](1691122292-490aa854a327e6e416b23603d195a17d.jpg) - 2. Special Partitions  特殊分区 - * Please contact the HPC administrator if you need to use below partitions, or you have special needs. + 2. Special Partitions  特殊分区 + * Please contact the HPC administrator if you need to use below partitions, or you have special needs. 如果您需要使用以下分区,或者有特殊需求,请联系HPC管理员。![](1691122292-e1f88732aadb6830326a20025beaa5c9.jpg) - 3. Job Priority 工作优先级 - * Instead of using FIFO scheduling scheme, the scheduling priority on the HPC depends on several factors: Job Size, Job Ages, Quality of Service (QoS), Usage history (Fair Share) and the Partition Properties. + 3. Job Priority 工作优先级 + * Instead of using FIFO scheduling scheme, the scheduling priority on the HPC depends on several factors: Job Size, Job Ages, Quality of Service (QoS), Usage history (Fair Share) and the Partition Properties. HPC 上的调度优先级不是使用 FIFO 调度方案,而是取决于几个因素:作业大小、作业期限、服务质量 (QoS)、使用历史记录(公平共享)和分区属性。 - * Ref.  [https://slurm.schedmd.com/classic\_fair\_share.html](https://slurm.schedmd.com/classic_fair_share.html) - 参考号https://slurm.schedmd.com/classic\_fair\_share.html - * We are working with external consultants to enhance the scheduling policy to ensure fairness. + * Ref.  [https://slurm.schedmd.com/classic\_fair\_share.html](https://slurm.schedmd.com/classic_fair_share.html) + 参考号 + * We are working with external consultants to enhance the scheduling policy to ensure fairness. 我们正在与外部顾问合作,完善调度政策以确保公平性。 - * We favour multi-node jobs by offering higher scheduling priorities for these partitions. However, intentionally requesting excessive resource to take advantage of this policy is strictly prohibited. Users’ actual workloads are closely monitored, and repeated offenders of this rule will lead to account suspensions. + * We favour multi-node jobs by offering higher scheduling priorities for these partitions. However, intentionally requesting excessive resource to take advantage of this policy is strictly prohibited. Users’ actual workloads are closely monitored, and repeated offenders of this rule will lead to account suspensions. 我们通过为这些分区提供更高的调度优先级来支持多节点作业。但是,严禁故意请求过多资源来利用此政策。用户的实际工作负载受到密切监控,屡次违反此规则将导致帐户被暂停。 -3. Job Scheduler and Submission +3. Job Scheduler and Submission 作业调度和提交 - 1. Job Scheduler 作业调度程序 - * Simple Linux Utility for Resource Management (SLURM) is an open source, fault-tolerant, and highly scalable cluster management and job scheduling system for large and small Linux clusters. It has been widely used in many HPC centres. + 1. Job Scheduler 作业调度程序 + * Simple Linux Utility for Resource Management (SLURM) is an open source, fault-tolerant, and highly scalable cluster management and job scheduling system for large and small Linux clusters. It has been widely used in many HPC centres. Simple Linux Utility for Resource Management (SLURM) 是一个开源、容错且高度可扩展的集群管理和作业调度系统,适用于大型和小型 Linux 集群。它已在许多HPC中心广泛使用。 - * Ref. https://slurm.schedmd.com/overview.html - 参考号https://slurm.schedmd.com/overview.html - 3. Job submission 作业提交 - * HPC users must familiarise themselves with SLURM commands in order to send their workloads to appropriate computational resources (CPU and GPU nodes). Four frequently used commands include sinfo, squeue, sbatch, & scancel. + * Ref. + 参考号 + 3. Job submission 作业提交 + * HPC users must familiarise themselves with SLURM commands in order to send their workloads to appropriate computational resources (CPU and GPU nodes). Four frequently used commands include sinfo, squeue, sbatch, & scancel. HPC 用户必须熟悉 SLURM 命令,才能将其工作负载发送到适当的计算资源(CPU 和 GPU 节点)。四个常用命令包括 sinfo、squeue、sbatch 和 scancel。 **Useful SLURM Commands: 有用的 SLURM 命令:** ![](1691122292-e18b35d37c1979a436e959875954f2bc.png) | | | | - | --- | --- | --- | + | --- | --- | --- | | **squeue 排队** | | to check status of your jobs
检查您的工作状态 | - | ![](1691122292-49f0ae851757d67f8292aa0de876ac3d.png) | | | - | _Job State Codes: 作业状态代码:
__(_[_https://slurm.schedmd.com/squeue.html#lbAG_](https://slurm.schedmd.com/squeue.html#lbAG)_)_
(https://slurm.schedmd.com/squeue.html#lbAG) | | | | + | ![](1691122292-49f0ae851757d67f8292aa0de876ac3d.png) | | | + | _Job State Codes: 作业状态代码:
__(_[_https://slurm.schedmd.com/squeue.html#lbAG_](https://slurm.schedmd.com/squeue.html#lbAG)_)_
() | | | | | RUNNING 跑步 | **R** | | The job currently is allocated to a node and is running.
该作业当前已分配到一个节点并正在运行。 | | PENDING 待办的 | **PD** | | The job is waiting for resource allocation. It will eventually run.
该作业正在等待资源分配。它最终会运行。 | | COMPLETING 正在完成 | **CG** | | The job is finishing but some processes are still active.
作业正在完成,但某些进程仍然处于活动状态。 | @@ -79,9 +87,9 @@ classoption: "UTF8" | SUSPENDED 暂停 | **S** | | A running job has been stopped with its cores released to other jobs.
正在运行的作业已停止,其核心被释放给其他作业。 | | STOPPED 停止 | **ST** | | A running job has been stopped with its cores retained.
正在运行的作业已停止,但保留了其核心。 | | | | - | --- | --- | - | _Job Reason Codes: 工作原因代码:
_([_https://slurm.schedmd.com/resource\_limits.html_](https://slurm.schedmd.com/resource_limits.html)_)_
(https://slurm.schedmd.com/resource\_limits.html) | - | Resource 资源 | The job is waiting for resources to become available and will eventually run.
该作业正在等待资源可用并最终运行。 | + | --- | --- | + | _Job Reason Codes: 工作原因代码:
_([_https://slurm.schedmd.com/resource\_limits.html_](https://slurm.schedmd.com/resource_limits.html)_)_
() | + | Resource 资源 | The job is waiting for resources to become available and will eventually run.
该作业正在等待资源可用并最终运行。 | | Priority 优先事项 | One or more higher priority jobs is in queue for running. Your job will eventually run.
一个或多个优先级较高的作业正在队列中等待运行。你的工作最终会运行。 | | | QOS(_Resource_)Limit QOS(资源)限制 | Maximum resource for your job’s QoS have been met.
已满足作业 QoS 的最大资源。 | | | _MaxJobsPerUser 每个用户的最大作业数_ | The maximum number of jobs a user can have running at a given time.
用户在给定时间可以运行的最大作业数。 | | @@ -94,16 +102,17 @@ classoption: "UTF8" | **scancel  scancel <作业 ID>** | | to kill a waiting or running job
终止正在等待或正在运行的作业 | ** Batch Submission: 批量提交:** - * A submission script is required to submit a batch job to the system. + * A submission script is required to submit a batch job to the system. 需要使用提交脚本来向系统提交批处理作业。 - * The syntax of the SLURM script is similar to a standard shell script: + * The syntax of the SLURM script is similar to a standard shell script: SLURM 脚本的语法类似于标准 shell 脚本: - * The main portion of the script is a standard Linux bash/cash script that will be executed on the compute nodes. + * The main portion of the script is a standard Linux bash/cash script that will be executed on the compute nodes. 该脚本的主要部分是一个标准的 Linux bash/cash 脚本,它将在计算节点上执行。 - * Lines beginning with #SBATCH are SLURM instructions will only be read by the SLURM scheduler, i.e. these SLURM instruction lines will only be considered as comments by the Linux shell. + * Lines beginning with #SBATCH are SLURM instructions will only be read by the SLURM scheduler, i.e. these SLURM instruction lines will only be considered as comments by the Linux shell. 以 #SBATCH 开头的行是 SLURM 指令,只会由 SLURM 调度程序读取,即这些 SLURM 指令行只会被 Linux shell 视为注释。 - * Here is an example of a submission script for a CPU node job. + * Here is an example of a submission script for a CPU node job. 以下是 CPU 节点作业的提交脚本示例。 + ```plain #!/bin/bash #SBATCH --partition=cpu_14d1n @@ -119,12 +128,14 @@ classoption: "UTF8" SIESTA=/cm/shared/apps/chemistry/siesta/4.1-266/bin/siesta OUTPUT=/home/johndoe/scratch/C60.output cd /home/johndoe/scratch/C60/1 - mpirun -genv OMP_NUM_THREADS=4 -genv I_MPI_PIN=1 -genv OMP_PROC_BIND=true -genv OMP_PLACES=cores $SIESTA < input.fdf > $OUTPUT + mpirun -genv OMP_NUM_THREADS=4 -genv I_MPI_PIN=1 -genv OMP_PROC_BIND=true -genv OMP_PLACES=cores$SIESTA < input.fdf >$OUTPUT date >>$OUTPUT ``` + ![](1691122292-40ed3afc19368cd16f83b79c3af38c23.jpg) - * Here is another example of a submission script for a one GPU job. + * Here is another example of a submission script for a one GPU job. 以下是一个 GPU 作业的提交脚本的另一个示例。 + ```plain #!/bin/bash #SBATCH --partition=gpu_7d1g @@ -140,173 +151,193 @@ classoption: "UTF8" module load cuda/11.0.2 cuda/blas/11.0.2 cuda/fft/11.0.2 OUTPUT=/home/johndoe/scratch/gpuburn.out cd /home/johndoe/scratch/gpu-burn/ - ./gpu_burn 100 >> $OUTPUT - date >> $OUTPUT + ./gpu_burn 100 >>$OUTPUT + date >>$OUTPUT ``` + ![](1691122292-0f6ddbca85fd766e5146365c5bc4b370.jpg) ** Interactive Scheduling: 互动调度:** WARNING: Users are not encouraged to use interactive scheduling for long production computation, and interactive jobs may be terminated due to the heavy workloads on the login node. Limitations on the use of Interactive Scheduling will be implemented soon. 警告:不鼓励用户使用交互式调度进行长时间的生产计算,并且交互式作业可能会由于登录节点上的繁重工作负载而终止。交互式调度的使用限制将很快实施。 - * For certain kinds of workloads that require manual manipulations during the computation, users may request for an interactive scheduling. + * For certain kinds of workloads that require manual manipulations during the computation, users may request for an interactive scheduling. 对于某些在计算过程中需要手动操作的工作负载,用户可以请求交互式调度。 - * Here is an example of an interactive job for requesting one GPU: + * Here is an example of an interactive job for requesting one GPU: 以下是请求一个 GPU 的交互式作业的示例: + ```plain srun --partition=gpu_7d1g --qos=normal --nodes=1 --cpus-per-task=4 --ntasks-per-node=1 --gres=gpu:1 --mem=50G -t1:00:0 --pty bash -i ``` + ![](1691122292-cc325823deae0c80892a4e086bd28ada.jpg) - 4. Quality of Service (QoS) + 4. Quality of Service (QoS) 服务质量 (QoS) - * QoS have been implemented in SLURM; it may affect the jobs in a few different aspects, e.g. + * QoS have been implemented in SLURM; it may affect the jobs in a few different aspects, e.g. QoS已在SLURM中实现;它可能会在几个不同方面影响工作,例如 - * Job Scheduling Priority (To be implemented in the future) + * Job Scheduling Priority (To be implemented in the future) 作业调度优先级(未来实施) - * Job Limit (To be implemented in the future) + * Job Limit (To be implemented in the future) 职位限制(未来实施) - * Charging (To be implemented in the future), and + * Charging (To be implemented in the future), and 充电(将来实施),以及 - * Access of Special Resources + * Access of Special Resources 特殊资源的获取 - * QoS will be added, deleted or modified in due course based on the needs without advance notice to users + * QoS will be added, deleted or modified in due course based on the needs without advance notice to users QoS将根据需要适时增加、删除或修改,恕不另行通知用户 - * Users can use command **showQos** to check all QoSs on the system + * Users can use command **showQos** to check all QoSs on the system 用户可以使用命令 showQos 查看系统上的所有 QoS ![](1691122292-0884d7533c2892fba6a3e4aaad07f4e2.png) - * There are 2 types of QoSs: + * There are 2 types of QoSs: 有 2 种类型的 QoS: - * Partition-QoS (i.e. gpu1 and gpu2) are used to define the partition properties, and they should not be defined inside the job script by users; they will be observed if a conflated User-QoS is defined within the job script. However, certain special QoS can override the limits defined by Partition-QoS (with OverParQOS Flag) + * Partition-QoS (i.e. gpu1 and gpu2) are used to define the partition properties, and they should not be defined inside the job script by users; they will be observed if a conflated User-QoS is defined within the job script. However, certain special QoS can override the limits defined by Partition-QoS (with OverParQOS Flag) Partition-QoS(即gpu1和gpu2)用于定义分区属性,用户不应在作业脚本中定义它们;如果在作业脚本中定义了合并的用户 QoS,则会观察到它们。然而,某些特殊的 QoS 可以覆盖 Partition-QoS 定义的限制(带有 OverParQOS 标志) - * User-QoS can be specified by users in the job script. Default QoS for most users is normal, (low for undergraduate projects and training courses). + * User-QoS can be specified by users in the job script. Default QoS for most users is normal, (low for undergraduate projects and training courses). User-QoS 可以由用户在作业脚本中指定。大多数用户的默认 QoS 是正常的(本科项目和培训课程较低)。 - * _normal_ QoS has a priority factor=25, 8 concurrent RUNNING JOBS are allowed per user; and 60 concurrent RUNNING JOBS for each departmental account (i.e. users from the same department) are allowed. + * _normal_ QoS has a priority factor=25, 8 concurrent RUNNING JOBS are allowed per user; and 60 concurrent RUNNING JOBS for each departmental account (i.e. users from the same department) are allowed. 普通 QoS 的优先级因子=25,每个用户允许 8 个并发运行作业;每个部门帐户(即来自同一部门的用户)允许同时运行 60 个作业。 - * _high_ & _extreme_ are reserved for future use when the charging scheme is effective. + * _high_ & _extreme_ are reserved for future use when the charging scheme is effective. high 和Extreme 保留供将来在收费方案有效时使用。 - * _highmem_ and _gpu\_vip_ are assigned to the users who can access the high memory node, and the whole GPU nodes, respectively, under special arrangements. + * _highmem_ and _gpu\_vip_ are assigned to the users who can access the high memory node, and the whole GPU nodes, respectively, under special arrangements. 在特殊安排下,highmem 和 gpu\_vip 分别分配给可以访问高端内存节点和整个 GPU 节点的用户。 - * _debug_ QoS is for users to test and verify their submission script before actual submission, so it has a very high priority factor and very tight resource limitations + * _debug_ QoS is for users to test and verify their submission script before actual submission, so it has a very high priority factor and very tight resource limitations debug QoS是为了用户在实际提交之前测试和验证他们的提交脚本,因此它具有非常高的优先级因素和非常严格的资源限制 - * _stingy_ QoS is for users who want to run jobs with the lowest priority without charging (UsageFactor=0). These jobs may be preempted (suspended, re-queued or terminated) when higher priority jobs are submitted to the system. + * _stingy_ QoS is for users who want to run jobs with the lowest priority without charging (UsageFactor=0). These jobs may be preempted (suspended, re-queued or terminated) when higher priority jobs are submitted to the system. 吝啬 QoS 适用于希望以最低优先级运行作业且不收费的用户 (UsageFactor=0)。当更高优先级的作业提交到系统时,这些作业可能会被抢占(挂起、重新排队或终止)。 + ## General Guidelines for Job Submission + 作业提交的一般准则 -1. **Favour Large Jobs Policy 支持大量就业政策** - * Users are encouraged to speed up the computational time by running parallel jobs across multiple nodes whenever possible, and thus we favour multi-node partitions by offering higher scheduling priorities within a shorter time limit. + +1. **Favour Large Jobs Policy 支持大量就业政策** + * Users are encouraged to speed up the computational time by running parallel jobs across multiple nodes whenever possible, and thus we favour multi-node partitions by offering higher scheduling priorities within a shorter time limit. 我们鼓励用户尽可能通过在多个节点上运行并行作业来加快计算时间,因此我们通过在更短的时间限制内提供更高的调度优先级来支持多节点分区。 - * However, using excessive number of CPU/Nodes will slow down the computation because communication latency overtakes the computational time. ([https://hpc.llnl.gov/tutorials/introduction-parallel-computing/limits-and-costs-parallel-programming](https://hpc.llnl.gov/tutorials/introduction-parallel-computing/limits-and-costs-parallel-programming)) - 然而,使用过多的 CPU/节点会减慢计算速度,因为通信延迟会超过计算时间。 (https://hpc.llnl.gov/tutorials/introduction-parallel-computing/limits-and-costs-parallel-programming) - * Users should benchmark their typical jobs with different combinations of MPI tasks and OpenMP threads on different number of nodes to obtain the best performance of the jobs. + * However, using excessive number of CPU/Nodes will slow down the computation because communication latency overtakes the computational time. ([https://hpc.llnl.gov/tutorials/introduction-parallel-computing/limits-and-costs-parallel-programming](https://hpc.llnl.gov/tutorials/introduction-parallel-computing/limits-and-costs-parallel-programming)) + 然而,使用过多的 CPU/节点会减慢计算速度,因为通信延迟会超过计算时间。 ( + * Users should benchmark their typical jobs with different combinations of MPI tasks and OpenMP threads on different number of nodes to obtain the best performance of the jobs. 用户应在不同数量的节点上使用 MPI 任务和 OpenMP 线程的不同组合对其典型作业进行基准测试,以获得作业的最佳性能。 -2. **Use Batch Submission 使用批量提交** - * Long interactive scheduling is strongly discouraged, and we will implement policy to regulate the unnecessary usage of it in the near future. +2. **Use Batch Submission 使用批量提交** + * Long interactive scheduling is strongly discouraged, and we will implement policy to regulate the unnecessary usage of it in the near future. 强烈建议不要长时间交互调度,我们将在不久的将来实施政策来规范不必要的使用。 - * Each interactive scheduling will consume certain resource on the login node shared amongst all login users. + * Each interactive scheduling will consume certain resource on the login node shared amongst all login users. 每次交互调度都会消耗所有登录用户共享的登录节点上的一定资源。 - * There is a risk for an abnormal job termination when the login node has encountered a network or system hiccup. + * There is a risk for an abnormal job termination when the login node has encountered a network or system hiccup. 当登录节点遇到网络或系统故障时,存在作业异常终止的风险。 - * Users should submit their jobs with batch scripts as far as possible. (i.e. avoid using interactive scheduling) + * Users should submit their jobs with batch scripts as far as possible. (i.e. avoid using interactive scheduling) 用户应尽可能使用批处理脚本提交作业。 (即避免使用交互式调度) - * Users should clearly specify the resource requirements, i.e. i) **Number of Nodes**, ii) **Number of MPI Tasks per Node**, iii) **OpenMP Threads per MPI Task**, iv) **Memory requirement per Node** in the submission script, otherwise the default value will be applied (i.e. 1 cpu and 3.5GB memory) despite the whole node being allocated. + * Users should clearly specify the resource requirements, i.e. i) **Number of Nodes**, ii) **Number of MPI Tasks per Node**, iii) **OpenMP Threads per MPI Task**, iv) **Memory requirement per Node** in the submission script, otherwise the default value will be applied (i.e. 1 cpu and 3.5GB memory) despite the whole node being allocated. 用户应在提交脚本中明确指定资源要求,即 i) 节点数,ii) 每个节点的 MPI 任务数,iii) 每个 MPI 任务的 OpenMP 线程数,iv) 每个节点的内存要求,否则将应用默认值(即 1 个 cpu 和 3.5GB 内存)尽管分配了整个节点。 - * Because of _backfilling algorithm_, waiting time can be significantly reduced if a smaller **Time Limit** has been specified in the job script. + * Because of _backfilling algorithm_, waiting time can be significantly reduced if a smaller **Time Limit** has been specified in the job script. 由于回填算法,如果在作业脚本中指定较小的时间限制,则可以显着减少等待时间。 -3. **Use of Local Scratch 使用局部划痕** -* Many jobs can take advantage of local scratch, and there is a 350GB local scratch at “/local” on each compute node. +3. **Use of Local Scratch 使用局部划痕** + +* Many jobs can take advantage of local scratch, and there is a 350GB local scratch at “/local” on each compute node. 许多作业可以利用本地暂存,每个计算节点上的“/local”都有 350GB 的本地暂存。 -* Users should remove all data on the local scratch when the computational task is completed. All data on the local scratch are not retrievable when the allocation is finished. +* Users should remove all data on the local scratch when the computational task is completed. All data on the local scratch are not retrievable when the allocation is finished. 当计算任务完成时,用户应该删除本地暂存上的所有数据。分配完成后,本地暂存上的所有数据都不可检索。 + ## Disk Storage and Quota + 磁盘存储和配额 -1. **General Storage Policies 一般存储策略** -1. User Guidelines 用户指南 -* It is the users’ responsibility to maintain and backup their own data on the HPC system. + +1. **General Storage Policies 一般存储策略** +1. User Guidelines 用户指南 + +* It is the users’ responsibility to maintain and backup their own data on the HPC system. 用户有责任维护和备份自己在 HPC 系统上的数据。 -* Users should only store research related data on the HPC storage system, and the HPC storage should not be considered as a permanent or backup data storage. All non-researched related or unused data found on the system will be erased without advance notice. +* Users should only store research related data on the HPC storage system, and the HPC storage should not be considered as a permanent or backup data storage. All non-researched related or unused data found on the system will be erased without advance notice. 用户应仅将研究相关数据存储在HPC存储系统上,并且HPC存储不应被视为永久或备份数据存储。系统上发现的所有非研究相关或未使用的数据将被删除,恕不另行通知。 -* Any illegal data or material found on the file system will be reported to the authority; related user accounts will be frozen, and the related data will be erased when the investigation is finished; users cannot claim for any loss because of this. +* Any illegal data or material found on the file system will be reported to the authority; related user accounts will be frozen, and the related data will be erased when the investigation is finished; users cannot claim for any loss because of this. 在文件系统中发现任何非法数据或材料将向主管部门报告;调查结束后,相关用户账户将被冻结,相关数据将被删除;用户不能因此而索赔。 -3. Data Backup 数据备份 -* There is **no** data backup service for the HPC service currently, but we will consider providing this service at a later stage. + +3. Data Backup 数据备份 + +* There is **no** data backup service for the HPC service currently, but we will consider providing this service at a later stage. 目前HPC服务还没有数据备份服务,但我们会考虑在后期提供此服务。 -3. **Disk Quota 磁盘配额** + +3. **Disk Quota 磁盘配额** The disk quota scheme has not been enforced yet, but it will be implemented in the near future. The following scheme has been proposed, and users may use it as a reference at this stage. 磁盘配额计划尚未实施,但将在不久的将来实施。提出了如下方案,现阶段用户可以作为参考。 - 1. Home Directory: 50GB fixed + 1. Home Directory: 50GB fixed 主目录:固定 50GB - * Persistent (i.e. no time limit) home space for user login. + * Persistent (i.e. no time limit) home space for user login. 用于用户登录的持久(即无时间限制)主空间。 - * Suitable for the following data: + * Suitable for the following data: 适用于以下数据: - * essential files for user login + * essential files for user login 用户登录的基本文件 - * users’ self-maintained libraries and applications + * users’ self-maintained libraries and applications 用户自行维护的库和应用程序 - * templates for inputs and submission scripts. + * templates for inputs and submission scripts. 输入和提交脚本的模板。 - 2. Scratch Directory: 300GB by default + 2. Scratch Directory: 300GB by default 暂存目录:默认300GB - * A working space for users to carry out computational jobs + * A working space for users to carry out computational jobs 供用户执行计算工作的工作空间 - * Storing inputs, outputs and temporary/scratch files + * Storing inputs, outputs and temporary/scratch files 存储输入、输出和临时/临时文件 - * Unused files will be erased regularly. + * Unused files will be erased regularly. 未使用的文件将定期删除。 - * Users should backup the important data on their own local storage when the job is finished. + * Users should backup the important data on their own local storage when the job is finished. 作业完成后,用户应将重要数据备份到自己的本地存储上。 - * Additional space can be arranged upon request with justification. Each case will be considered individually. + * Additional space can be arranged upon request with justification. Each case will be considered individually. 可根据要求并有理由安排额外的空间。每个案例都会被单独考虑。 - 4. NAS (Will be implemented in future) + 4. NAS (Will be implemented in future) NAS(未来将实现) -## + +## + Software Stacks 软件堆栈 -1. **Environment Modules 环境模块 + +1. **Environment Modules 环境模块 ** Lmod Environment Modules have been used to manage the software packages on the HPC system, and users can dynamically change their software environment through modulefiles. Lmod环境模块已用于管理HPC系统上的软件包,用户可以通过模块文件动态更改其软件环境。 ([https://lmod.readthedocs.io/en/latest/](https://lmod.readthedocs.io/en/latest/)) - ( https://lmod.readthedocs.io/en/latest/) + ( ) There is a public modulefile set managed by the Computing Services Centre (CSC); the environment variable MODULEPATH has been set as follows by default. 有一个由计算服务中心(CSC)管理的公共模块文件集;环境变量 MODULEPATH 默认设置如下。 + ```plain MODULEPATH=/cm/local/modulefiles:/etc/modulefiles:/usr/share/modulefiles:/usr/share/Modules/modulefiles:/cm/shared/modulefiles/compiler:/cm/shared/modulefiles/library:/cm/shared/modulefiles/mpi:/cm/shared/apps/mpi/hpcx/2.8.0/modulefiles ``` + ![](1691122292-8486866cfc269077bb48bc6d524e30f9.png) The current modulefile set is minimal, and we are preparing a more comprehensive set which covers more scientific applications and programming tools. Users will be informed when the new environment set is ready. 当前的模块文件集很小,我们正在准备一个更全面的集,其中涵盖更多的科学应用程序和编程工具。当新环境集准备就绪时,用户将收到通知。 -2. **Use of Environment Modules +2. **Use of Environment Modules 环境模块的使用** -1. Common module commands 常用模块命令 +1. Common module commands 常用模块命令 ![](1691122292-6144a7220c868c033852e25e95f4e653.jpg) -2. Append self-maintained module set +2. Append self-maintained module set 追加自维护模块集 Users can create their own modulefile set by appending the path of the directories which contain the modulefiles to the MODULEPATH variable. 用户可以通过将包含模块文件的目录路径附加到 MODULEPATH 变量来创建自己的模块文件集。 The syntax of modulefile can be found on this web page: modulefile的语法可以在这个网页上找到: [https://lmod.readthedocs.io/en/latest/100\_modulefile\_examples.html](https://lmod.readthedocs.io/en/latest/100_modulefile_examples.html) -4. **Singularity Containers 奇点容器** +4. **Singularity Containers 奇点容器** Users are encouraged to install their own application packages as a Singularity container image ([https://sylabs.io/guides/3.7/user-guide/](https://sylabs.io/guides/3.7/user-guide/)) on their own desktop/workstation/labtop, and run it on Burgundy’s GPU node.  This is the only method to run customised system environment (e.g. a different Linux distro such as Ubuntu 18) or libraries (e.g. python 2, unsupported libgc) or optimised AI packages prepared by Nvidia. - 鼓励用户将自己的应用程序包作为 Singularity 容器映像(https://sylabs.io/guides/3.7/user-guide/)安装在自己的桌面/工作站/labtop 上,并在 Burgundy 的 GPU 节点上运行。这是运行定制系统环境(例如不同的 Linux 发行版,如 Ubuntu 18)或库(例如 python 2、不支持的 libgc)或 Nvidia 准备的优化 AI 包的唯一方法。 + 鼓励用户将自己的应用程序包作为 Singularity 容器映像( 上,并在 Burgundy 的 GPU 节点上运行。这是运行定制系统环境(例如不同的 Linux 发行版,如 Ubuntu 18)或库(例如 python 2、不支持的 libgc)或 Nvidia 准备的优化 AI 包的唯一方法。 Users can build their own singularity with the following reference: 用户可以参考以下内容构建自己的奇点: ([https://sylabs.io/guides/3.7/user-guide/quick\_start.html#build-images-from-scratch](https://sylabs.io/guides/3.7/user-guide/quick_start.html#build-images-from-scratch)) - (https://sylabs.io/guides/3.7/user-guide/quick\_start.html#build-images-from-scratch) + ( | | | | | --- | --- | --- | - | i) Prepare a definition file under a X86-64 Linux environment.
i) 在X86-64 Linux环境下准备定义文件。

* In this example, we will install the packages, such as gcc and python, with apt-get on Ubuntu 18.04 images.
在此示例中,我们将使用 apt-get 在 Ubuntu 18.04 映像上安装 gcc 和 python 等软件包。
* CUDA 10.0 libraries directly downloaded from Nvidia will be installed.
将安装直接从 Nvidia 下载的 CUDA 10.0 库。
* Tensorflow (with GPU supported), numpy and OpenCV will be installed with pip within the image subsequently.
随后,Tensorflow(支持 GPU)、numpy 和 OpenCV 将与 pip 一起安装在映像中。

![](1691122292-6e26dd7d0953931e1f41c6145656c166.jpg) | + | i) Prepare a definition file under a X86-64 Linux environment.
i) 在X86-64 Linux环境下准备定义文件。

*In this example, we will install the packages, such as gcc and python, with apt-get on Ubuntu 18.04 images.
在此示例中,我们将使用 apt-get 在 Ubuntu 18.04 映像上安装 gcc 和 python 等软件包。
* CUDA 10.0 libraries directly downloaded from Nvidia will be installed.
将安装直接从 Nvidia 下载的 CUDA 10.0 库。
* Tensorflow (with GPU supported), numpy and OpenCV will be installed with pip within the image subsequently.
随后,Tensorflow(支持 GPU)、numpy 和 OpenCV 将与 pip 一起安装在映像中。

![](1691122292-6e26dd7d0953931e1f41c6145656c166.jpg) | | ii) Build image with Singularity command. This example was done on a CentOS Linux VM (Virtual Box) under MacOS
ii) 使用 Singularity 命令构建图像。此示例是在 MacOS 下的 CentOS Linux VM(Virtual Box)上完成的

![](1691122292-0edfb8f23c13acfb1f34dd776187503d.jpg) | | iii) Upload the Singularity image to HPC Login Node
iii) 将 Singularity 镜像上传到 HPC 登录节点

![](1691122292-f2cbb19cf66c90f12754f9bec2447fc9.jpg) | - | iv) Submit the job and request the resource; in this example, an interactive schedule is used for illustration purpose only, and users should submit batch jobs if possible.
iv) 提交作业并请求资源;在此示例中,交互式计划仅用于说明目的,用户应尽可能提交批处理作业。

* Login to system, and submit an interactive job
登录系统,提交交互式作业

![](1691122292-41c17c50caf5648b13c2a8aee0db0dd4.jpg)
* When the resource is allocated, the prompt will change to indicate which node has been assigned (i.e. hpc-gpu005 in this case).
分配资源时,提示符将更改以指示已分配哪个节点(即本例中的 hpc-gpu005)。

For illustration purpose, we show the distro information of the Base System; it is a CentOS 8
为了便于说明,我们显示了基本系统的发行版信息;它是 CentOS 8

![](1691122292-097fc6f1ad267d1ad23cbca58ed4af83.jpg)
* Execute Linux commands from the singularity image.
从奇点映像执行 Linux 命令。
First, we ask to show the distro information of the client (the image), and it is a Ubuntu 18.04
首先,我们要求显示客户端(镜像)的发行版信息,它是 Ubuntu 18.04

![](1691122292-75f5f171f9d4085ea8f4db5458aa8879.jpg)
* Then, we call python3 from the image.
然后,我们从图像中调用 python3。

![](1691122292-fdb787ad1ae674a0909f4c6b1155e120.jpg) | -5. **Other Licensed Software 其他许可软件** -1. Matlab MATLAB + | iv) Submit the job and request the resource; in this example, an interactive schedule is used for illustration purpose only, and users should submit batch jobs if possible.
iv) 提交作业并请求资源;在此示例中,交互式计划仅用于说明目的,用户应尽可能提交批处理作业。

*Login to system, and submit an interactive job
登录系统,提交交互式作业

![](1691122292-41c17c50caf5648b13c2a8aee0db0dd4.jpg)
* When the resource is allocated, the prompt will change to indicate which node has been assigned (i.e. hpc-gpu005 in this case).
分配资源时,提示符将更改以指示已分配哪个节点(即本例中的 hpc-gpu005)。

For illustration purpose, we show the distro information of the Base System; it is a CentOS 8
为了便于说明,我们显示了基本系统的发行版信息;它是 CentOS 8

![](1691122292-097fc6f1ad267d1ad23cbca58ed4af83.jpg)
*Execute Linux commands from the singularity image.
从奇点映像执行 Linux 命令。
First, we ask to show the distro information of the client (the image), and it is a Ubuntu 18.04
首先,我们要求显示客户端(镜像)的发行版信息,它是 Ubuntu 18.04

![](1691122292-75f5f171f9d4085ea8f4db5458aa8879.jpg)
* Then, we call python3 from the image.
然后,我们从图像中调用 python3。

![](1691122292-fdb787ad1ae674a0909f4c6b1155e120.jpg) | +5. **Other Licensed Software 其他许可软件** +1. Matlab MATLAB A copy of Matlab has been installed, and you can find Matlab R2002b at the following location: Matlab 的副本已安装,您可以在以下位置找到 Matlab R2002b:   /cm/shared/apps/maths/matlab/R2020b/bin /cm/shared/apps/maths/matlab/R2020b/bin CityU’s Matlab license servers are reachable to all nodes, and users may include this in their license files if they prefer to run their own copy of Matlab. 城大的 Matlab 许可证服务器可访问所有节点,如果用户希望运行自己的 Matlab 副本,则可以将其包含在其许可证文件中。 + ```plain ############################################################ SERVER berkeley101.ad.cityu.edu.hk 005056981E16 27000 @@ -315,7 +346,8 @@ Software Stacks 软件堆栈 USE_SERVER ############################################################ ``` -2. Other Commercial Software + +2. Other Commercial Software 其他商业软件 Due to the license issue, the CSC will help to install shared license to the license server, but we cannot provide support for any user-owned license packages. Please contact the distributor of the software for support. 由于许可证问题,CSC将帮助将共享许可证安装到许可证服务器,但我们无法为任何用户拥有的许可证包提供支持。请联系该软件的经销商以获得支持。 diff --git "a/HPC/\346\210\220\345\212\237\347\232\204sbatch.md" "b/HPC/\346\210\220\345\212\237\347\232\204sbatch.md" index e171cdc..78d0af2 100644 --- "a/HPC/\346\210\220\345\212\237\347\232\204sbatch.md" +++ "b/HPC/\346\210\220\345\212\237\347\232\204sbatch.md" @@ -4,6 +4,7 @@ documentclass: "ctexart" classoption: "UTF8" --- # scratch.sh + ```bash #!/bin/bash #SBATCH --partition=gpu_short @@ -17,6 +18,6 @@ classoption: "UTF8" module load cuda/11.6.0 OUTPUT=/home/zihanwu7/scratch/output.txt cd /home/zihanwu7/scratch/own_transformer -python main.test.py >> $OUTPUT -date >> $OUTPUT +python main.test.py >>$OUTPUT +date >>$OUTPUT ``` diff --git a/Linux/conda_script.md b/Linux/conda_script.md index 62331fb..3ec75ec 100644 --- a/Linux/conda_script.md +++ b/Linux/conda_script.md @@ -4,27 +4,35 @@ documentclass: "ctexart" classoption: "UTF8" --- # Managing conda environments + ## Method 1 + ```bash conda activate ``` + ```bash -vi $(dirname $(which python))/../etc/conda/activate.d/env_vars.sh +vi$(dirname$(which python))/../etc/conda/activate.d/env_vars.sh ``` + ```env_vars.sh #!/bin/bash export OLD_PATH=$PATH export PATH=***:$PATH ``` + ```bash -vi $(dirname $(which conda))/../etc/conda/deactivate.d/env_vars.sh +vi$(dirname$(which conda))/../etc/conda/deactivate.d/env_vars.sh ``` + ```env_vars.sh #!/bin/bash export PATH=$OLD_PATH unset OLD_PATH ``` + ## Method 2 (didn't test) + ```bash conda activate conda env config vars set = diff --git a/Linux/openvpn.md b/Linux/openvpn.md index b394d72..702d453 100644 --- a/Linux/openvpn.md +++ b/Linux/openvpn.md @@ -4,24 +4,30 @@ documentclass: "ctexart" classoption: "UTF8" --- # Open VPN + 1. install docker Note: check if daemon is running + ```bash sudo systemctl status docker ``` + 2. install openvpn + ```bash OVPN_DATA="ovpn-zihan" - docker volume create --name $OVPN_DATA - docker run -v $OVPN_DATA:/etc/openvpn --rm kylemanna/openvpn ovpn_genconfig -u udp://vpn.zihanng.shop - docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn ovpn_initpki - docker run -v $OVPN_DATA:/etc/openvpn -d -p 1194:1194/udp --cap-add=NET_ADMIN kylemanna/openvpn + docker volume create --name$OVPN_DATA + docker run -v$OVPN_DATA:/etc/openvpn --rm kylemanna/openvpn ovpn_genconfig -u udp://vpn.zihanng.shop + docker run -v$OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn ovpn_initpki + docker run -v$OVPN_DATA:/etc/openvpn -d -p 1194:1194/udp --cap-add=NET_ADMIN kylemanna/openvpn # or - # docker run --privileged -v $OVPN_DATA:/etc/openvpn -d -p 1194:1194/udp kylemanna/openvpn - docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn easyrsa build-client-full zihan nopass - docker run -v $OVPN_DATA:/etc/openvpn --rm kylemanna/openvpn ovpn_getclient zihan > zihan.ovpn + # docker run --privileged -v$OVPN_DATA:/etc/openvpn -d -p 1194:1194/udp kylemanna/openvpn + docker run -v$OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn easyrsa build-client-full zihan nopass + docker run -v$OVPN_DATA:/etc/openvpn --rm kylemanna/openvpn ovpn_getclient zihan > zihan.ovpn ``` + 3. pull the zihan.ovpn file to local machine + ```bash rsync -avzP zihan_aws:zihan.ovpn . ``` diff --git a/Linux/overleaf.md b/Linux/overleaf.md index 414dbba..d11f006 100644 --- a/Linux/overleaf.md +++ b/Linux/overleaf.md @@ -4,39 +4,59 @@ documentclass: "ctexart" classoption: "UTF8" --- # 如何在远程服务器上布置 Overleaf 并通过子域名访问 + 本文档将介绍如何在远程服务器上布置 Overleaf,并通过子域名访问该服务。主要步骤包括服务器配置、端口映射、域名解析和 HTTPS 配置。 + ## 1. 服务器配置 + ### 1.1 获取 Overleaf 镜像 + 从 Overleaf 官方仓库获取 Docker 镜像: + ```bash git clone https://github.com/overleaf/toolkit.git cd toolkit ``` + ### 1.2 启动 Overleaf + 初始化 Overleaf: + ```bash bin/init ``` + 使用 Docker Compose 启动 Overleaf 服务: + ```bash sudo bin/up ``` + ## 2. 配置 FRP 进行端口映射 + 我们需要使用 FRP 将没有公共 IP 的服务器(如 CityU 服务器)上的端口映射到 Azure 服务器,并通过 Azure 服务器进行外部访问。 + ### 2.1 在 Azure 服务器上配置 FRP 服务端 + 创建 `frps.ini` 文件: + ```ini [common] bind_port = 7000 vhost_http_port = 8081 ``` + 在 Azure 服务器的网络规则界面打开端口 7000 和 8081。 启动 FRP 服务端: + ```bash ./frps -c frps.ini ``` + ### 2.2 在 CityU 服务器上配置 FRP 客户端 + 创建 `frpc.ini` 文件: + ```ini [common] server_addr = @@ -47,53 +67,77 @@ local_ip = 127.0.0.1 local_port = 80 custom_domains = overleaf.zihanng.shop ``` + 启动 FRP 客户端: + ```bash ./frpc -c frpc.ini ``` + ## 3. 配置域名解析 + 将子域名 `overleaf.zihanng.shop` 解析到 Azure 服务器的公共 IP 地址。在域名注册商的管理控制台中,添加 A 记录: + ```txt Hostname: overleaf.zihanng.shop Type: A Value: TTL: 300 ``` + ## 4. 配置 Apache 以反向代理 Overleaf 服务 + ### 4.1 安装 Apache + 在 Azure 服务器上安装 Apache: + ```bash sudo apt install -y apache2 ``` + ### 4.2 配置 Apache 反向代理 + 启用必要的模块: + ```bash sudo a2enmod proxy proxy_http proxy_wstunnel rewrite headers ``` + 编辑 Apache 虚拟主机配置文件 `/etc/apache2/sites-available/overleaf.zihanng.shop.conf`: + ```apache ServerName overleaf.zihanng.shop ProxyPreserveHost On ProxyPass / http://127.0.0.1:80/ ProxyPassReverse / http://127.0.0.1:80/ - ErrorLog ${APACHE_LOG_DIR}/overleaf_error.log - CustomLog ${APACHE_LOG_DIR}/overleaf_access.log combined + ErrorLog${APACHE_LOG_DIR}/overleaf_error.log + CustomLog${APACHE_LOG_DIR}/overleaf_access.log combined ``` + 启用站点并重新加载 Apache: + ```bash sudo a2ensite overleaf.zihanng.shop.conf sudo systemctl reload apache2 ``` + ## 5. 配置 HTTPS + 使用 Certbot 获取 SSL 证书: + ```bash sudo apt install -y certbot python3-certbot-apache sudo certbot --apache -d overleaf.zihanng.shop ``` + 按照提示完成证书的生成和配置,成功后会自动配置 HTTPS。 + ## 6. 创建 Overleaf 管理员账号 + 通过访问 注册管理员账号。 + ## 总结 + 通过上述步骤,我们成功在远程服务器上布置了 Overleaf 服务,并通过子域名实现了外部访问。通过 Apache 配置反向代理,并使用 Certbot 配置 HTTPS,确保了服务的安全性和可访问性。 diff --git a/Linux/zsh_config.md b/Linux/zsh_config.md index 03f572d..3b88425 100644 --- a/Linux/zsh_config.md +++ b/Linux/zsh_config.md @@ -4,25 +4,34 @@ documentclass: "ctexart" classoption: "UTF8" --- # zsh config + ## Install zsh + ```bash sudo apt install zsh ``` + ## oh-my-zsh + ```bash sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" ``` + ## plugins + ```bash # Assuming you have git installed # If not, simply do "sudo yum install git -y" -git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting -git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions +git clone https://github.com/zsh-users/zsh-syntax-highlighting.git${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting +git clone https://github.com/zsh-users/zsh-autosuggestions${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions # And then add them to "~/.zshrc" file plugins=(git zsh-autosuggestions zsh-syntax-highlighting) ``` + ## powerlevel10k + ```bash -git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k +git clone --depth=1 https://github.com/romkatv/powerlevel10k.git${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k ``` + And then add `ZSH_THEME="powerlevel10k/powerlevel10k"` to `~/.zshrc`. diff --git "a/Linux/\345\256\211\350\243\205 Linux.md" "b/Linux/\345\256\211\350\243\205 Linux.md" index 713229a..227887a 100644 --- "a/Linux/\345\256\211\350\243\205 Linux.md" +++ "b/Linux/\345\256\211\350\243\205 Linux.md" @@ -4,30 +4,46 @@ documentclass: "ctexart" classoption: "UTF8" --- # 安装 Linux + 1. 在windows 下,使用`universal USB installer` 在移动硬盘的一个10G的小分区上,做一个启动盘(之前用U盘做可能是因为盘坏了,不行。)在 `installer` 里,选择Fat32, 同时会帮你格式化。 2. 安装`Ubuntu`时,选择自定义安装,然后覆盖掉之前的安装,寻找ex4文件系统即可。 + ## Vscode + 启用了Remote Tunnel + ## anaconda + 安装了miniforge(mambaforge) from github仓库脚本 + ## zsh + apt 安装的 zsh + ## git + 安装git from apt 安装curl 安装oh my zsh 关闭自动睡眠 + ```bash sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target ``` + ## 安装 gcc + ```bash sudo apt install build-essential ``` + ## 安装p10k + ## 备份 Linux + Using `Timeshift` 在Ubuntu上将磁盘重新格式化为ext4文件系统,可以按照以下步骤操作: + 1. 使用lsblk命令识别要格式化的磁盘设备名称,例如/dev/sdb。 2. 卸载该磁盘已经挂载的任何分区,使用umount命令,例如umount /dev/sdb1。 3. 使用fdisk命令进入交互模式,对该磁盘进行分区操作。删除旧分区并创建新分区。 @@ -37,45 +53,63 @@ Using `Timeshift` 7. 等待格式化完成。使用df -Th命令检查文件系统是否已成为ext4。 8. 最后可以在/etc/fstab中添加挂载信息,并使用mount命令挂载分区到指定目录。 这个过程将完全抹掉磁盘数据并将其格式化为ext4文件系统。建议先做好数据备份,然后按步骤操作,完成磁盘到ext4的转换 formatting。 + ## zsh 禁止输入文件夹名就打开文件夹 + 在`~/.zshrc`中添加 + ``` zsh setopt no_auto_pushd ``` + ## zsh reveal conda environment + p10k choose the first style + ## install zsh conda completion + " + ## teamviewer assignment + - `sudo passwd` to set root password - `su` to log in with root - /path/to/teamviewer --allowRoot + ## cmake + - `sudo apt install cmake` + ## opencv + - `sudo apt install libopencv-dev python3-opencv` - Vulkan: `sudo apt install libvulkan-dev` + ## Lapack + - `sudo apt install liblapack-dev` - in `CMakeLists.txt` add `find_package(LAPACK REQUIRED)` + ## Example script for Ubuntu + ```bash sudo apt install zsh sudo apt install git sudo apt install curl sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target -git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k +git clone --depth=1 https://github.com/romkatv/powerlevel10k.git${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k # and add ZSH_THEME="powerlevel10k/powerlevel10k" to ~/.zshrc -git clone https://github.com/esc/conda-zsh-completion ${ZSH_CUSTOM:=~/.oh-my-zsh/custom}/plugins/conda-zsh-completion +git clone https://github.com/esc/conda-zsh-completion${ZSH_CUSTOM:=~/.oh-my-zsh/custom}/plugins/conda-zsh-completion # And add lines in `.zshrc` -git clone https://github.com/zsh-users/zsh-history-substring-search ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-history-substring-search -git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions -git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting +git clone https://github.com/zsh-users/zsh-history-substring-search${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-history-substring-search +git clone https://github.com/zsh-users/zsh-autosuggestions${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions +git clone https://github.com/zsh-users/zsh-syntax-highlighting.git${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting ``` + ```.zshrc plugins=(git zsh-autosuggestions gitignore conda-zsh-completion zsh-syntax-highlighting) -source $ZSH/oh-my-zsh.sh +source$ZSH/oh-my-zsh.sh autoload -U compinit && compinit # conda-zsh-completion zstyle ':completion::complete:*' use-cache 1 diff --git a/LiteratureNotes/he2024CoclusteringFederatedRecommender.md b/LiteratureNotes/he2024CoclusteringFederatedRecommender.md index 2e6f4e2..161bc78 100644 --- a/LiteratureNotes/he2024CoclusteringFederatedRecommender.md +++ b/LiteratureNotes/he2024CoclusteringFederatedRecommender.md @@ -6,11 +6,15 @@ classoption: "UTF8" --- zotero-key: PMJDJUAW zt-attachments: + - "14576" title: Co-clustering for federated recommender system citekey: he2024CoclusteringFederatedRecommender + --- + # Co-clustering for federated recommender system + [Zotero](zotero://select/library/items/PMJDJUAW) [attachment]() > [!note] Page 3821 > @@ -51,36 +55,36 @@ citekey: he2024CoclusteringFederatedRecommender > > 为了将协同效应整合到学习过程中,聚合在显示出相似偏好的用户组内进行,因为如果用户对特定类别的项目表现出共同的兴趣,他们可能对其他一些项目也有共同的偏好。因此,这种聚合方法有助于知识的传递,同时保护用户隐私。值得注意的是,这种方法不需要辨别特定项目类型的偏好或厌恶。 > -> 在每轮通信中,服务器需要服务一个核心客户端 $c \in U$ 和一个项目类别 $k$,特别是找到相对于项目类别 $k$ 的客户端 $c$ 的邻居。为此,服务器首先对所有参与客户端上传的项目网络进行全局聚合,然后生成一个项目成员关系 $M$(将在第3.2节详细解释),详细说明哪些项目属于哪些类别。通过指定项目类别 $k$,我们可以获取属于类别 $k$ 的所有项目,表示为 $M_k = \{i \mid i \in I, M[i] = k \}$。然后我们计算核心客户端与所有其他参与者在其项目网络的选定项目类别上的相似性。这里我们采用余弦相似度: +> 在每轮通信中,服务器需要服务一个核心客户端$c \in U$和一个项目类别$k$,特别是找到相对于项目类别$k$的客户端$c$的邻居。为此,服务器首先对所有参与客户端上传的项目网络进行全局聚合,然后生成一个项目成员关系$M$(将在第3.2节详细解释),详细说明哪些项目属于哪些类别。通过指定项目类别$k$,我们可以获取属于类别$k$的所有项目,表示为$M_k = \{i \mid i \in I, M[i] = k \}$。然后我们计算核心客户端与所有其他参与者在其项目网络的选定项目类别上的相似性。这里我们采用余弦相似度: > -> $$ s_u = \sum_{i \in M_k} \frac{V_{c,i} \cdot V_{u,i}}{|V_{c,i}| \cdot |V_{u,i}|}, \quad u \in P $$ +>$$s_u = \sum_{i \in M_k} \frac{V_{c,i} \cdot V_{u,i}}{|V_{c,i}| \cdot |V_{u,i}|}, \quad u \in P$$ > -> 其中 $V_{c,i}$ 和 $V_{u,i}$ 分别表示核心客户端 $c$ 和参与用户 $u$ 在类别 $k$ 下的项目 $i$ 的向量。$s_u$ 是核心客户端 $c$ 和参与用户 $u$ 在项目类别 $k$ 上的相似度得分。$P$ 是参与客户端集。通过这个公式,我们可以获得相似度得分列表 $S = \{s_1, s_2, \ldots, s_{|P|} \}$。 +> 其中$V_{c,i}$和$V_{u,i}$分别表示核心客户端$c$和参与用户$u$在类别$k$下的项目$i$的向量。$s_u$是核心客户端$c$和参与用户$u$在项目类别$k$上的相似度得分。$P$是参与客户端集。通过这个公式,我们可以获得相似度得分列表$S = \{s_1, s_2, \ldots, s_{|P|} \}$。 > -> 在计算所有参与者的余弦相似度得分后,为了识别相似组 $D_s$ 和不相似组 $D_{dis}$,我们提出使用相似度得分的第一个肘点来将参与客户端分为 $D_s$ 和 $D_{dis}$,本质上是相似度得分进展率发生显著变化的点。为了找到这个分割点,我们首先对相似度得分进行排序,表示为 $\{s_1', s_2', \ldots, s_{|P|}'\}$(这里 $s_1'$ 不再对应于用户1的相似度得分,而是具有最高相似度得分的用户),并构建一条连接相似度得分的第一个点和最后一个点的线: +> 在计算所有参与者的余弦相似度得分后,为了识别相似组$D_s$和不相似组$D_{dis}$,我们提出使用相似度得分的第一个肘点来将参与客户端分为$D_s$和$D_{dis}$,本质上是相似度得分进展率发生显著变化的点。为了找到这个分割点,我们首先对相似度得分进行排序,表示为$\{s_1', s_2', \ldots, s_{|P|}'\}$(这里$s_1'$不再对应于用户1的相似度得分,而是具有最高相似度得分的用户),并构建一条连接相似度得分的第一个点和最后一个点的线: > -> $$ L(x) = s_1' + x (s_{|P|}' - s_1') $$ +>$$L(x) = s_1' + x (s_{|P|}' - s_1')$$ > -> 其中 $x$ 是确定点在直线 $L(x)$ 上位置的标量参数。对于相似度得分中的每个点 $s_u$,我们计算其到直线 $L(x)$ 的垂直距离,这是通过将 $s_u$ 投影到 $L(x)$ 上并计算 $s_u$ 与其投影之间的欧几里得距离来实现的。令 $\mathbf{h}_u = s_u - s_1'$ 是从第一个点 $s_1'$ 到点 $s_u$ 的向量。将 $\mathbf{h}_u$ 投影到 $L(x)$ 上的标量投影为: +> 其中$x$是确定点在直线$L(x)$上位置的标量参数。对于相似度得分中的每个点$s_u$,我们计算其到直线$L(x)$的垂直距离,这是通过将$s_u$投影到$L(x)$上并计算$s_u$与其投影之间的欧几里得距离来实现的。令$\mathbf{h}_u = s_u - s_1'$是从第一个点$s_1'$到点$s_u$的向量。将$\mathbf{h}_u$投影到$L(x)$上的标量投影为: > -> $$ x_u = \frac{\mathbf{h}_u \cdot (s_{|P|}' - s_1')}{|s_{|P|}' - s_1'|^2} $$ +>$$x_u = \frac{\mathbf{h}_u \cdot (s_{|P|}' - s_1')}{|s_{|P|}' - s_1'|^2}$$ > -> 点 $s_u$ 到 $L(x)$ 的垂直距离 $d_u$ 可以计算为: +> 点$s_u$到$L(x)$的垂直距离$d_u$可以计算为: > -> $$ d_u = |\mathbf{h}_u - x_u (s_{|P|}' - s_1')| $$ +>$$d_u = |\mathbf{h}_u - x_u (s_{|P|}' - s_1')|$$ > -> 具有最大距离 $d_e$ 到直线 $L(x)$ 的点 $e$ 被认为是肘点。这个点本质上划定了在选定项目类别上的核心客户端的最佳邻居,表示为相似组 $D_s$,否则为不相似组 $D_{dis}$: +> 具有最大距离$d_e$到直线$L(x)$的点$e$被认为是肘点。这个点本质上划定了在选定项目类别上的核心客户端的最佳邻居,表示为相似组$D_s$,否则为不相似组$D_{dis}$: > -> $$ +>$$ > \begin{cases} > u \in D_s, & \text{if } d_u \geq d_e, \\ > u \in D_{dis}, & \text{if } d_u < d_e, > \end{cases} -> $$ +>$$ > > 一旦分组完成,将在相似组内进行组聚合以传递协作信息: > -> $$ V_s \leftarrow \frac{1}{|D_s|} \sum_{u \in D_s} V_u $$ +>$$V_s \leftarrow \frac{1}{|D_s|} \sum_{u \in D_s} V_u$$ > -> 相似组中的所有参与者将用组模型 $V_s$ 更新他们的项目嵌入网络。通过这种协同聚类方法,同一组内的用户可能有相似的偏好,从而信息可以更自信地在它们之间共享。不相似组内的客户端将被忽略,以防止在异质数据之间传递低质量的知识。 +> 相似组中的所有参与者将用组模型$V_s$更新他们的项目嵌入网络。通过这种协同聚类方法,同一组内的用户可能有相似的偏好,从而信息可以更自信地在它们之间共享。不相似组内的客户端将被忽略,以防止在异质数据之间传递低质量的知识。 > ^SIATBHJGaM47RZX4Hp3 diff --git a/LiteratureNotes/long2005CoclusteringBlockValue.md b/LiteratureNotes/long2005CoclusteringBlockValue.md index 384e4cb..d780897 100644 --- a/LiteratureNotes/long2005CoclusteringBlockValue.md +++ b/LiteratureNotes/long2005CoclusteringBlockValue.md @@ -6,129 +6,147 @@ classoption: "UTF8" --- zotero-key: RJAJK78V zt-attachments: - - "791" + +- "791" title: Co-clustering by block value decomposition citekey: long2005CoclusteringBlockValue + --- + # Co-clustering by block value decomposition + [Zotero](zotero://select/library/items/RJAJK78V) [attachment]() > [!note] Page 635 -> +> > Dyadic -> +> > --- > 🔤二元🔤 > ^9I337M8UaU95TA7PHp1 > [!note] Page 635 -> +> > intertwining -> +> > --- > 🔤交织在一起🔤 > ^XGFPA7LYaU95TA7PHp1 > [!note] Page 636 -> +> > We are interested in simultaneously clustering X into k disjoint clusters and Y into l disjoint clusters. This is equiv- alent to finding block structure of the matrix Z, i.e., finding k × l submatrices of Z such that the elements within each submatrix are similar to each other and elements from different submatrices are dissimilar to each other. > ^LER3K477aU95TA7PHp2 > [!note] Page 636 -> +> > In the traditional one-way clustering, given the cluster centers and the weights that denote degrees of observations associated with their clusters, one can approximate the original data by linear combinations of the cluster centers. Similarly, we should be able to ”reconstruct” the original data matrix by the linear combinations of the block centers. -> +> > --- > 和传统聚类类似,可以这么理解。 > 传统:每个element可以表示为聚类中心的线性表示 -> co-clustering: $Z \sim RBC$, B就像聚类中心 +> co-clustering:$Z \sim RBC$, B就像聚类中心 > ^66H3G3EHaU95TA7PHp2 > [!note] Page 637 -> +> > Under the BVD framework, the combinations of the components also have an intuitive interpretation. RB is the matrix containing the basis for the column space of Z and BC contains the basis for the row space of Z. For example, for a word-by-document matrix Z, each column of RB captures a base topic of a particular document cluster and each row of BC captures a base topic of a word cluster. -> +> > --- > 在文本数据集中,矩阵分解的意义。 > ^5G5X7V89aU95TA7PHp3 > [!note] Page 637 -> +> > Comparing with SVD-based approaches, there are two main differences between BVD and SVD. -> +> > --- > 🔤与基于 SVD 的方法相比,BVD 和 SVD 之间有两个主要区别。🔤 +> > 1. 求和更有意义 > 2. 基向量方向和cluster联系更紧密 > 都是可解释性上的区别 > ^NRPLVT7IaU95TA7PHp3 > [!note] Page 637 -> +> > The objective function in (2) is convex in R, B and C respectively. However, it is not convex in all of them simultaneously. Thus, it is unrealistic to expect an algorithm to find the global minimum. We derive an EM [1] style algorithm that converges to a local minimum by iteratively updating the decomposition using a set of multiplicative updating rules. -> +> > --- > 使用iterative方法的原因 > ^8G9ZT6VCaU95TA7PHp3 > [!note] Page 638 -> +> > Definition 3. -> +> > --- > 对称情况 > ^XHQ8JH3YaU95TA7PHp4 > [!note] Page 638 -> +> > Data Sets and Parameter Settings -> +> > --- > 我们使用20新闻组数据集(NG20)和CLASSIC3数据集的各种子集来进行性能评估。NG20数据集包含来自20个不同新闻组的大约20,000篇新闻组文章。我们完全复制了也被\ [8, 10\]用于文档共聚类的数据集,以确保评估中的可直接比较性。许多新闻组共享相似的主题,大约4.5%的文档被交叉发布,使得某些新闻组之间的界限相当模糊。为了使我们的比较与现有算法一致,我们重建了\ [8, 10\]中使用的NG20的各种子集,即删除停用词,忽略文件头并根据互信息选择前2000个词。与\ [10\]中一样,我们在文章中包含主题行。子集的具体细节如表1所示。由于每个词-文档矩阵的文档向量被归一化为单位L2范数,在NBVD的实现中,我们归一化了RB的每一列以获得单位L2范数。假设RB被归一化为RBV。文档的聚类标签由V−1C给出,而不是C。我们使用混淆矩阵的准确度来衡量聚类性能,混淆矩阵由获得的聚类和“真实”类给出。混淆矩阵中的每个条目(i,j)表示聚类i中属于真实类j的文档数量。具体而言,我们使用微平均精度。 -> -> +> +> > 主要思路为: +> > - 使用 20 新闻组数据集等进行评估 > - 对数据集进行预处理(移除停用词等)以保证可比性 > - 使用混淆矩阵和微平均精度评测聚类性能 > ^LDN4ETKJaU95TA7PHp4 > [!note] Page 638 -> +> > Experiment on Word-Document Data -> +> > --- > 这一部分提供了实证证据,以展示作为一种通用的共聚类算法,NBVD如何在与NMF[6]以及另外两种共聚类算法——信息论共聚类(ICC)[8]和迭代双重聚类算法(IDC)[10]相比较时,提高了文档聚类的准确性。在实验中,初始矩阵按以下方式生成:R和C的所有元素都是从0到1的均匀分布中生成的,而B的所有元素则简单地赋值为数据矩阵的平均值。由于NBVD算法无法保证找到全局最小值,因此多次运行该算法并使用不同的初始值,选择目标值最小的一次试验是有益的。实际上,通常几次试验就足够了。在本文报道的实验中,每个测试运行中进行了三次NBVD试验,最终结果是二十次测试运行的平均值。NMF的实验也以同样的方式进行。表2记录了在CLASSIC3数据集上使用NMF和NBVD分别获得的两个混淆矩阵,其中包含3个单词簇,即真实单词簇的数量。观察到NBVD以0.9879的微平均精度提取了原始簇,而NMF的微平均精度为0.9866。NBVD和NMF在CLASSIC3数据集上表现几乎相同并不令人惊讶。这是因为当行簇和列簇之间存在完美的一对一对应时,块值矩阵B接近于单位矩阵,NMF等同于NBVD。表3显示了数据集CLASSIC3的一个块值矩阵。表3的完美对角结构表明了CLASSIC3的文档簇和单词簇之间的一对一对应结构。表4显示了在Multi5数据集上NBVD和NMF分别获得的两个混淆矩阵。NBVD和NMF分别产生了0.944和0.884的微平均精度。这个实验表明,在Multi5数据集上,NBVD的性能优于NMF。与CLASSIC3相比,Multi5具有更复杂的隐藏块结构,文档簇和单词簇之间没有简单的一对一关系。这表明,通过利用行聚类和列聚类的双重性,NBVD比NMF更有能力发现数据的复杂隐藏块结构。表5显示了在所有NG20数据集上的微平均精度测量结果。所有NBVD的精度值都是通过在真实文档簇的数量和通过额外实验找到的相应最佳单词簇数量上运行NBVD获得的,这些额外实验评估了在不同数量的单词簇下的精度(由于空间限制,细节省略)。引用自[8]和[10]的ITC和IDC的峰值精度值。在所有数据集上,NBVD的表现都优于其单边对应的NMF。这个结果证明了需要利用单词聚类和文档聚类之间的双重性。与另外两种最新的共聚类算法相比,NBVD在几乎所有数据集上的精度都有明显的提高。特别是在具有更多簇的复杂数据集上观察到了更大的改进,这是实践中的典型场景。 > ^3NHK2PAJaU95TA7PHp4 -# Basic Information: +> +# Basic Information + - Title: Co-clustering by Block Value Decomposition (块值分解的共聚类) - Authors: Bo Long, Zhongfei (Mark) Zhang, Philip S. Yu - Affiliation: Computer Science Dept., SUNY Binghamton (纽约州立大学宾汉姆顿分校计算机科学系) - Keywords: Co-clustering, Clustering, Matrix Decomposition, Dyadic Data, Hidden Block Structure, Block Value Decomposition (BVD) - URLs: [Paper](https://chatwithpaper.org/link_to_paper), [GitHub: None] -# 论文简要 : + +# 论文简要 + - 本文提出了一种新的共聚类框架,即块值分解(BVD),用于处理二维数据矩阵的隐藏块结构,提出了一种特定的共聚类算法,针对非负二元数据,通过迭代计算三个分解矩阵,证明了算法的收敛性,并进行了广泛的实验评估,展示了该框架及算法的有效性和潜力。 -# 背景信息: + +# 背景信息 + - 论文背景: 共聚类在许多领域中都有广泛的应用,而对于二维数据矩阵,共聚类通常比传统的单向聚类更加理想。 - 过去方案: 大多数聚类文献侧重于单边聚类算法,但最近共聚类因其在基因表达数据分析和文本挖掘等问题中的应用而受到广泛关注。 - 论文的Motivation: 共聚类能够更有效地处理高维稀疏数据,并且能够同时提供行聚类和列聚类,因此在许多应用中更为理想。作者提出了块值分解(BVD)框架,旨在探索二维二元数据矩阵中的潜在块结构,通过三个分解矩阵来实现对原始数据矩阵的重构。 -# 方法: + +# 方法 + - a. 理论背景: - - 本文介绍了一种新的用于二元数据的共聚类框架,称为块值分解(Block Value Decomposition,BVD)。该框架将二元数据矩阵分解为三个部分:行系数矩阵R,块值矩阵B和列系数矩阵C。提出的共聚类算法基于乘法更新规则迭代计算这三个分解矩阵。算法通过在每次迭代中交织行聚类和列聚类来进行隐式自适应降维。通过广泛的实验评估,证明了该框架和算法的有效性。 + - 本文介绍了一种新的用于二元数据的共聚类框架,称为块值分解(Block Value Decomposition,BVD)。该框架将二元数据矩阵分解为三个部分:行系数矩阵R,块值矩阵B和列系数矩阵C。提出的共聚类算法基于乘法更新规则迭代计算这三个分解矩阵。算法通过在每次迭代中交织行聚类和列聚类来进行隐式自适应降维。通过广泛的实验评估,证明了该框架和算法的有效性。 - b. 技术路线: - - 本文描述了非负块值分解(Non-negative Block Value Decomposition,NBVD)算法及其特殊情况下的对称非负块值分解。NBVD算法旨在最小化目标函数,同时对矩阵R、B和C施加非负约束。算法涉及对R、B和C的迭代更新规则,时间复杂度为O(t(k + l)nm),其中t是迭代次数。文本还介绍了局部最小值的必要条件以及对称NBVD特殊情况下的更新规则。 -# 结果: + - 本文描述了非负块值分解(Non-negative Block Value Decomposition,NBVD)算法及其特殊情况下的对称非负块值分解。NBVD算法旨在最小化目标函数,同时对矩阵R、B和C施加非负约束。算法涉及对R、B和C的迭代更新规则,时间复杂度为O(t(k + l)nm),其中t是迭代次数。文本还介绍了局部最小值的必要条件以及对称NBVD特殊情况下的更新规则。 + +# 结果 + - a. 详细的实验设置: - - 使用20-Newsgroup数据集(NG20)和CLASSIC3数据集进行性能评估。 - - NG20数据集包含约20,000篇从20个不同的Usenet新闻组收集的新闻文章。 - - 为了与现有算法进行比较,使用各种NG20的子集进行重构。 - - 子集是通过去除停用词、忽略文件头部,并基于互信息选择前2000个词语来创建的。 - - 文章的主题行包含在内。 - - 文档向量被归一化为单位L2范数。 - - 使用混淆矩阵给出的准确率来衡量聚类性能,并使用微平均精度作为度量指标。 - - 使用NBVD算法以及NMF、ICC和IDC算法进行比较,对单词-文档数据进行聚类。 - - 使用均匀分布在0到1之间生成初始矩阵。 - - NBVD算法在不同的初始值下运行多次,找到目标值最小的试验。 - - 每次测试运行中进行三次NBVD试验,最终结果取二十次测试运行的平均值。 - - 实验结果显示,与NMF、ICC和IDC算法相比,NBVD提高了文档聚类的准确性。 - - 实验还表明,NBVD在具有更多聚类的数据集上表现更好。 - - 还进行了接近度数据的实验,以展示对称NBVD算法在图分区上的潜力。 - - 与平均关联(AA)和归一化割(NC)方法相比,对称NBVD算法表现出更好的性能。 - - 实验使用与之前相同的预处理步骤的NG20数据集。 - - 文档的接近度矩阵确定为W = ZT Z,其中Z是单词-文档共现矩阵。 - - 使用余弦相似度衡量文档之间的相似性。 - - 使用微平均精度作为度量指标。 - - 对称NBVD算法在每次测试运行中进行3次试验。 - - 性能结果显示,对称NBVD算法在图分区问题上优于AA和NC方法。 -# Note: + - 使用20-Newsgroup数据集(NG20)和CLASSIC3数据集进行性能评估。 + - NG20数据集包含约20,000篇从20个不同的Usenet新闻组收集的新闻文章。 + - 为了与现有算法进行比较,使用各种NG20的子集进行重构。 + - 子集是通过去除停用词、忽略文件头部,并基于互信息选择前2000个词语来创建的。 + - 文章的主题行包含在内。 + - 文档向量被归一化为单位L2范数。 + - 使用混淆矩阵给出的准确率来衡量聚类性能,并使用微平均精度作为度量指标。 + - 使用NBVD算法以及NMF、ICC和IDC算法进行比较,对单词-文档数据进行聚类。 + - 使用均匀分布在0到1之间生成初始矩阵。 + - NBVD算法在不同的初始值下运行多次,找到目标值最小的试验。 + - 每次测试运行中进行三次NBVD试验,最终结果取二十次测试运行的平均值。 + - 实验结果显示,与NMF、ICC和IDC算法相比,NBVD提高了文档聚类的准确性。 + - 实验还表明,NBVD在具有更多聚类的数据集上表现更好。 + - 还进行了接近度数据的实验,以展示对称NBVD算法在图分区上的潜力。 + - 与平均关联(AA)和归一化割(NC)方法相比,对称NBVD算法表现出更好的性能。 + - 实验使用与之前相同的预处理步骤的NG20数据集。 + - 文档的接近度矩阵确定为W = ZT Z,其中Z是单词-文档共现矩阵。 + - 使用余弦相似度衡量文档之间的相似性。 + - 使用微平均精度作为度量指标。 + - 对称NBVD算法在每次测试运行中进行3次试验。 + - 性能结果显示,对称NBVD算法在图分区问题上优于AA和NC方法。 + +# Note + - 本总结源自于LLM的总结,请注意数据判别. Power by ChatPaper. End. diff --git a/Love/idea_influence_function_fine-tuning.md b/Love/idea_influence_function_fine-tuning.md index c508ee2..6cf330a 100644 --- a/Love/idea_influence_function_fine-tuning.md +++ b/Love/idea_influence_function_fine-tuning.md @@ -4,15 +4,19 @@ documentclass: "ctexart" classoption: "UTF8" --- # Fine-tuning + ## Problem + Original problem notation: -- $D = \{ (x_i, y_i) \}_{i=1}^n$ is a dataset of $n$ samples -- $f_{\theta}(x)$ is a model with parameters $\theta$ -- $L(f_{\theta}(x), y)$ is a loss function -- $\theta^*$ is the optimal parameter -- $\mathcal{L}(\theta) = \frac{1}{|D|} \sum_{(x, y) \in D} L(f_{\theta}(x), y)$ is the empirical risk -- $\theta^* = \arg \min_{\theta} \mathcal{L}(\theta) = \arg \min_{\theta} |D| \mathcal{L}(\theta) = \arg \min_{\theta} \sum_{(x, y) \in D} L(f_{\theta}(x), y)$ + +-$D = \{ (x_i, y_i) \}_{i=1}^n$is a dataset of$n$samples +-$f_{\theta}(x)$is a model with parameters$\theta$ +-$L(f_{\theta}(x), y)$is a loss function +-$\theta^*$is the optimal parameter +-$\mathcal{L}(\theta) = \frac{1}{|D|} \sum_{(x, y) \in D} L(f_{\theta}(x), y)$is the empirical risk +-$\theta^* = \arg \min_{\theta} \mathcal{L}(\theta) = \arg \min_{\theta} |D| \mathcal{L}(\theta) = \arg \min_{\theta} \sum_{(x, y) \in D} L(f_{\theta}(x), y)$ Fine-tuning problem: -- $D_f = \{ (x_i, y_i) \}_{i=1}^m$ is a dataset of $m$ samples, where $m \ll n$ -- Fine-tuning loss function: $\mathcal{L}_f(\theta) = \frac{1}{|D_f|} \sum_{(x, y) \in D_f} L(f_{\theta}(x), y)$ -原来的loss function: $\mathcal{L}(\theta) = \frac{1}{|D|} \sum_{(x, y) \in D} L(f_{\theta}(x), y)$, 新的loss function: $\mathcal{L}_f(\theta) = \frac{1}{|D_f| + |D|} \sum_{(x, y) \in D_f \cup D} L(f_{\theta}(x), y)$ +-$D_f = \{ (x_i, y_i) \}_{i=1}^m$is a dataset of$m$samples, where$m \ll n$ + +- Fine-tuning loss function:$\mathcal{L}_f(\theta) = \frac{1}{|D_f|} \sum_{(x, y) \in D_f} L(f_{\theta}(x), y)$ +原来的loss function:$\mathcal{L}(\theta) = \frac{1}{|D|} \sum_{(x, y) \in D} L(f_{\theta}(x), y)$, 新的loss function:$\mathcal{L}_f(\theta) = \frac{1}{|D_f| + |D|} \sum_{(x, y) \in D_f \cup D} L(f_{\theta}(x), y)$ diff --git "a/MacOS/\350\207\252\345\212\251\347\255\276\345\220\215macOS app.md" "b/MacOS/\350\207\252\345\212\251\347\255\276\345\220\215macOS app.md" index b3839bf..e3a36c7 100644 --- "a/MacOS/\350\207\252\345\212\251\347\255\276\345\220\215macOS app.md" +++ "b/MacOS/\350\207\252\345\212\251\347\255\276\345\220\215macOS app.md" @@ -5,12 +5,14 @@ classoption: "UTF8" --- 自助签名macOS app 下载的Golden Dict++ 应用显示损坏,发现是code sign问题,于是应该 + 1. 在 Key Chain 中申请证书:钥匙串助理 -> 证书助理 -> 从颁发机构请求证书 2. 导出到磁盘之后,再导入钥匙串,选代码签名 3. ![[Pasted image 20230712105909.png]] 4. ```sudo codesign --force --deep --sign 吴子晗 /Applications/GoldenDict.app``` -5. $$ +5.$$ \ell_2 \text {-norm } + $$ 1. 从终端打开obsidian可以commit with gpg -2. obsidian git 中 环境变量添加 `GPG_TTY=$(tty)`, `PATH` 添加 `/opt/homebrew/bin/` 成功 \ No newline at end of file +2. obsidian git 中 环境变量添加 `GPG_TTY=$(tty)`, `PATH` 添加 `/opt/homebrew/bin/` 成功 diff --git a/Math/CUR_Decomposition.md b/Math/CUR_Decomposition.md index b99b737..0b86020 100644 --- a/Math/CUR_Decomposition.md +++ b/Math/CUR_Decomposition.md @@ -4,6 +4,7 @@ documentclass: "ctexart" classoption: "UTF8" --- # CUR Decomposition + $$ A \simeq C U R \\ C = A(:,q) \\ @@ -17,5 +18,6 @@ A \in \mathbb{R}^{m \times n} \\ A = VSW^\top \\ S \in \mathbb{R}^{k \times k} \\ $$ -DEIM then is used to find $p$ and $q$ from $V$ and $W$. +DEIM then is used to find$p$and$q$from$V$and$W$. + ## $p$ diff --git a/Math/Construction_of_Ito_Intergration.md b/Math/Construction_of_Ito_Intergration.md index a7d5120..5957c6f 100644 --- a/Math/Construction_of_Ito_Intergration.md +++ b/Math/Construction_of_Ito_Intergration.md @@ -4,16 +4,22 @@ documentclass: "ctexart" classoption: "UTF8" --- # Construction of Ito Intergration + ## 1. Idea + Just like the construction of Lebesgue integral, we first define the integral for *elementary* (simple functions), then extend it to the class of where the integral is well-defined. + ### Elementary Functions -For a given partition $P = \{t_0, t_1, \cdots, t_n\}$ of $[0, T]$, we define the elementary function $\phi$ as + +For a given partition$P = \{t_0, t_1, \cdots, t_n\}$of$[0, T]$, we define the elementary function$\phi$as $$ \phi = \sum_{i=0}^{n-1} e_i(\omega) \chi_{[t_{i}, t_{i+1})}(\omega) $$ -where $e_i$ is a $\mathcal{F}_{t_{i}}$-measurable random variable. +where$e_i$is a$\mathcal{F}_{t_{i}}$-measurable random variable. + ## 2. Ito Isometry -For $\phi$ is an elementary function, we define the Ito integral of $\phi$ as + +For$\phi$is an elementary function, we define the Ito integral of$\phi$as $$ \int_{S}^{T} \phi(t, \omega) \mathrm{d}B_t = \sum_{i=0}^{n-1} e_i(\omega) (B_{t_{i+1}} - B_{t_{i}}) $$ @@ -21,96 +27,102 @@ The Ito isometry states that $$ \mathbb{E} \left[ \left( \int_{S}^{T} \phi(t, \omega) \mathrm{d}B_t \right)^2 \right] = \mathbb{E} \left[ \int_{S}^{T} \phi^2(t, \omega) \mathrm{d}t \right] $$ + ## 3. Ito Integral + ### $\mathcal{V}$ -Denote the class we want to define the integral as $\mathcal{V}$. Let $\mathcal{V} = \mathcal{V}(S, T)$ be the class of all functions $f(t, \omega): [0, \infty) \times \Omega \rightarrow \mathbb{R}$ such that -1. $f(t, \omega)$ is $\mathcal{B} \times \mathcal{F}$-measurable, where $\mathcal{B}$ is the Borel $\sigma$-algebra on $[0, \infty)$. -2. $f(t, \omega): \omega \mapsto f(t, \omega)$ is $\mathcal{F}_t$-measurable for each $t \geq 0$. -3. $\mathbb{E} \left[ \int_{0}^{\infty} f^2(t, \omega) \mathrm{d}t \right] < \infty$. + +Denote the class we want to define the integral as$\mathcal{V}$. Let$\mathcal{V} = \mathcal{V}(S, T)$be the class of all functions$f(t, \omega): [0, \infty) \times \Omega \rightarrow \mathbb{R}$such that + +1.$f(t, \omega)$is$\mathcal{B} \times \mathcal{F}$-measurable, where$\mathcal{B}$is the Borel$\sigma$-algebra on$[0, \infty)$. +2.$f(t, \omega): \omega \mapsto f(t, \omega)$is$\mathcal{F}_t$-measurable for each$t \geq 0$. +3.$\mathbb{E} \left[ \int_{0}^{\infty} f^2(t, \omega) \mathrm{d}t \right] < \infty$. + ### Step 1 + Handle the **bounded** and **continuous** case. -*Bounded and continuous functions in $\mathcal{V}$ can be approximated by elementary functions.* -**Lemma 1.** If $g \in \mathcal{V}$ is bounded and continuous, then there exists a sequence of elementary functions $\phi_n \in \mathcal{V}$ such that +*Bounded and continuous functions in$\mathcal{V}$can be approximated by elementary functions.* +**Lemma 1.** If$g \in \mathcal{V}$is bounded and continuous, then there exists a sequence of elementary functions$\phi_n \in \mathcal{V}$such that $$ \mathbb{E} \left[ \int_{S}^{T} (g(t, \omega) - \phi_n(t, \omega))^2 \mathrm{d}t \right] \rightarrow 0 $$ -as $n \rightarrow \infty$. +as$n \rightarrow \infty$. Here bounded convergence theorem is used. -> **Theorem 1.** (Bounded Convergence Theorem) Let $f_n$ be a sequence of bounded measurable functions that are supported on a set $E$ of finite measure. If $f_n \rightarrow f$ pointwise a.e. on $E$, then +> **Theorem 1.** (Bounded Convergence Theorem) Let$f_n$be a sequence of bounded measurable functions that are supported on a set$E$of finite measure. If$f_n \rightarrow f$pointwise a.e. on$E$, then > -> $$ +>$$ > \lim_{n \rightarrow \infty} \int_{E} |f_n - f| \mathrm{d}\mu = 0 -> $$ +>$$ > Consequently, -> $$ +>$$ > \lim_{n \rightarrow \infty} \int_{E} f_n \mathrm{d}\mu = \int_{E} f d\mu -> $$ +>$$
Proof of Lemma 1. -Define $\phi_n$ as +Define$\phi_n$as $$ \phi_n(t, \omega) = \sum_{i=0}^{n-1} g(t_i, \omega) \chi_{[t_{i}, t_{i+1})}(t) $$ -thus $\phi_n$ is an elementary function. +thus$\phi_n$is an elementary function. $$ \int_S^T (g-\phi_n)^2 \mathrm{d}t \rightarrow 0, \text{as } n \rightarrow \infty \tag{1} $$ -since $g$ is continuous and $[S, T]$ is compact. +since$g$is continuous and$[S, T]$is compact.
Proof of (1) -Given $\omega$, $\forall \epsilon > 0$, $\exists \delta > 0$ such that -$\forall t, t' \in [S, T]$ with $|t - t'| < \delta$, we have $|g(t, \omega) - g(t', \omega)| < \sqrt{\frac{\epsilon}{T-S}}$. Choose $n$ such that $\frac{1}{n} < \frac{\delta}{2}$, then +Given$\omega$,$\forall \epsilon > 0$,$\exists \delta > 0$such that +$\forall t, t' \in [S, T]$with$|t - t'| < \delta$, we have$|g(t, \omega) - g(t', \omega)| < \sqrt{\frac{\epsilon}{T-S}}$. Choose$n$such that$\frac{1}{n} < \frac{\delta}{2}$, then $$ |g(t, \omega) - \phi_n(t, \omega)|^2 = |g(t, \omega) - g(t_i, \omega)|^2 < \frac{\epsilon}{T-S} $$ -since $|t - t_i| < \frac{2}{n} < \delta$. +since$|t - t_i| < \frac{2}{n} < \delta$. Thus we have $$ \int_S^T (g-\phi_n)^2 \mathrm{d}t < \frac{\epsilon}{T-S} \int_S^T \mathrm{d}t = \epsilon $$
-Denote $I_n(\omega) = \int_S^T (g-\phi_n)^2 \mathrm{d}t$, Eq.(1) suggests that $I_n(\omega) \rightarrow 0$ pointwisely respect to $\omega$. -Here we just need to verify that $I_n(\omega)$ is bounded and measurable, then we can apply the bounded convergence theorem. -- Boundedness: $I_n(\omega) \leq \int_S^T g^2 \mathrm{d}t < M^2 (T-S)$, where $M$ is the bound of $g$. -- Measurability: $I_n(\omega)$ is measurable since $g$ is measurable according to Fubini's theorem. +Denote$I_n(\omega) = \int_S^T (g-\phi_n)^2 \mathrm{d}t$, Eq.(1) suggests that$I_n(\omega) \rightarrow 0$pointwisely respect to$\omega$. +Here we just need to verify that$I_n(\omega)$is bounded and measurable, then we can apply the bounded convergence theorem. +- Boundedness:$I_n(\omega) \leq \int_S^T g^2 \mathrm{d}t < M^2 (T-S)$, where$M$is the bound of$g$. +- Measurability:$I_n(\omega)$is measurable since$g$is measurable according to Fubini's theorem.
### Step 2 Handle the **bounded** (but not necessarily continuous) case. -Bounded functions in $\mathcal{V}$ can be approximated by bounded and continuous functions. -**Lemma 2.** If $h \in \mathcal{V}$ is bounded, then $\exists$ bounded and continuous functions $g_n$ such that +Bounded functions in$\mathcal{V}$can be approximated by bounded and continuous functions. +**Lemma 2.** If$h \in \mathcal{V}$is bounded, then$\exists$bounded and continuous functions$g_n$such that $$ \mathbb{E} \left[ \int_{S}^{T} (h - g_n)^2 \mathrm{d}t \right] \rightarrow 0, \text{as } n \rightarrow \infty $$
Proof of Lemma 2. -Suppose $h$ is bounded by $M$, first $\phi_n : \mathbb{R} \rightarrow \mathbb{R}$ is constructed as follows: -1. $\phi_n(x) =0 $ for $x \le -\cfrac{1}{n}$ and $x \ge 0$. -2. $\int_{-\infty}^{\infty} \phi_n(x) \mathrm{d}x = 1$. -Then define $g_n$ as +Suppose$h$is bounded by$M$, first$\phi_n : \mathbb{R} \rightarrow \mathbb{R}$is constructed as follows: +1.$\phi_n(x) =0$for$x \le -\cfrac{1}{n}$and$x \ge 0$. +2.$\int_{-\infty}^{\infty} \phi_n(x) \mathrm{d}x = 1$. +Then define$g_n$as $$ g_n(t, \omega) = \int_{-\infty}^{\infty} \phi_n(t-s) h(s, \omega) \mathrm{d}s $$ -Then $g_n$ is bounded and continuous for each $\omega$. And $g_n$ is $\mathcal{F}_t$-measurable for each $t$ since $h$ is $\mathcal{F}_t$-measurable. Also $\phi_n$ and $g_n$ are seleted for +Then$g_n$is bounded and continuous for each$\omega$. And$g_n$is$\mathcal{F}_t$-measurable for each$t$since$h$is$\mathcal{F}_t$-measurable. Also$\phi_n$and$g_n$are seleted for $$ \int_{S}^{T} (h - g_n)^2 \mathrm{d}t \rightarrow 0, \text{as } n \rightarrow \infty $$ -- $\phi_n$: +-$\phi_n$: -- $h$: +-$h$: -- $g_n$ ($n=5$): +-$g_n$($n=5$):
### Step 3 Handle the **general** case. -Every function in $\mathcal{V}$ can be approximated by bounded functions. -**Lemma 3.** If $f \in \mathcal{V}$, then there exists a sequence of bounded functions $h_n \in \mathcal{V}$ such that +Every function in$\mathcal{V}$can be approximated by bounded functions. +**Lemma 3.** If$f \in \mathcal{V}$, then there exists a sequence of bounded functions$h_n \in \mathcal{V}$such that $$ \mathbb{E} \left[ \int_{S}^{T} (f - h_n)^2 \mathrm{d}t \right] \rightarrow 0, \text{as } n \rightarrow \infty $$
Proof of Lemma 3. -For each $n$, let $h_n$ satisfy +For each$n$, let$h_n$satisfy $$ h_n(t, \omega) = \begin{cases} f(t, \omega), & |f(t, \omega)| \le n \\ @@ -121,16 +133,16 @@ $$ By **Dominated Convergence Theorem**, we have the desired result.
### Definition of Ito Integral -**Definition 1.** If $f \in \mathcal{V}$, one can find a sequence of elementary functions $\phi_n \in \mathcal{V}$ such that +**Definition 1.** If$f \in \mathcal{V}$, one can find a sequence of elementary functions$\phi_n \in \mathcal{V}$such that $$ \mathbb{E} \left[ \int_{S}^{T} (f - \phi_n)^2 \mathrm{d}t \right] \rightarrow 0, \text{as } n \rightarrow \infty $$ -Then we define the Ito integral of $f$ as +Then we define the Ito integral of$f$as $$ \int_{S}^{T} f(t, \omega) \mathrm{d}B_t = \lim_{n \rightarrow \infty} \int_{S}^{T} \phi_n(t, \omega) \mathrm{d}B_t $$ -The limit exists in $L^2(\Omega)$ since $L^2(\Omega)$ is complete and -Denote $J_n(\omega) = \int_{S}^{T} \phi_n(t, \omega) \mathrm{d}B_t$, then +The limit exists in$L^2(\Omega)$since$L^2(\Omega)$is complete and +Denote$J_n(\omega) = \int_{S}^{T} \phi_n(t, \omega) \mathrm{d}B_t$, then $$ J_{n+k}(\omega) - J_n(\omega) = \int_{S}^{T} (\phi_{n+k} - \phi_n) \mathrm{d}B_t -$$ \ No newline at end of file +$$ diff --git "a/Math/Kolmogorov\342\200\231s extension theorem.md" "b/Math/Kolmogorov\342\200\231s extension theorem.md" index cc6a092..7294f39 100644 --- "a/Math/Kolmogorov\342\200\231s extension theorem.md" +++ "b/Math/Kolmogorov\342\200\231s extension theorem.md" @@ -4,20 +4,21 @@ documentclass: "ctexart" classoption: "UTF8" --- # Kolmogorov’s extension theorem -For all $t_1, \ldots, t_k \in T, k \in \mathbf{N}$ let $\nu_{t_1, \ldots, t_k}$ be probability measures on $\mathbf{R}^{n k}$ s.t. + +For all$t_1, \ldots, t_k \in T, k \in \mathbf{N}$let$\nu_{t_1, \ldots, t_k}$be probability measures on$\mathbf{R}^{n k}$s.t. $$ \nu_{t_{\sigma(1)}, \cdots, t_{\sigma(k)}}\left(F_1 \times \cdots \times F_k\right)=\nu_{t_1, \cdots, t_k}\left(F_{\sigma^{-1}(1)} \times \cdots \times F_{\sigma^{-1}(k)}\right) $$ -for all permutations $\sigma$ on $\{1,2, \ldots, k\}$ and +for all permutations$\sigma$on$\{1,2, \ldots, k\}$and $$ \nu_{t_1, \ldots, t_k}\left(F_1 \times \cdots \times F_k\right)=\nu_{t_1, \ldots, t_k, t_{k+1}, \ldots, t_{k+m}}\left(F_1 \times \cdots \times F_k \times \mathbf{R}^n \times \cdots \times \mathbf{R}^n\right) $$ -for all $m \in \mathbf{N}$, where (of course) the set on the right hand side has a total of $k+m$ factors. -Then there exists a probability space $(\Omega, \mathcal{F}, P)$ and a stochastic process $\left\{X_t\right\}$ on $\Omega, X_t: \Omega \rightarrow \mathbf{R}^n$, s.t. +for all$m \in \mathbf{N}$, where (of course) the set on the right hand side has a total of$k+m$factors. +Then there exists a probability space$(\Omega, \mathcal{F}, P)$and a stochastic process$\left\{X_t\right\}$on$\Omega, X_t: \Omega \rightarrow \mathbf{R}^n$, s.t. $$ \nu_{t_1, \ldots, t_k}\left(F_1 \times \cdots \times F_k\right)=P\left[X_{t_1} \in F_1, \cdots, X_{t_k} \in F_k\right], $$ -for all $t_i \in T, k \in \mathbf{N}$ and all Borel sets $F_i$. +for all$t_i \in T, k \in \mathbf{N}$and all Borel sets$F_i$. Kolmogorov的延拓定理解决了在给定各个坐标空间上的概率测度的情况下,如何构造一个概率测度来描述乘积空间的问题。 简单来说,Kolmogorov的延拓定理允许我们为定义在不同空间上的一组随机变量构造一个联合概率测度。 它提供了一种将概率测度从有限维空间延拓到无限维乘积空间的方法。 @@ -28,34 +29,39 @@ Kohlrausch条件(无信息传递性):该条件要求当从一个坐标空 满足这些条件,就可以使用Kolmogorov的延拓定理构造一个满足一致性要求的概率测度。 [Wikipedia for Kolmogorov 延拓定理](https://en.wikipedia.org/wiki/Kolmogorov_extension_theorem) -Let $T$ denote some Interval (thought of as "time"), and let $n \in \mathbb{N}$. For each $k \in \mathbb{N}$ and finite sequence of distinct times $t_{1}, \dots, t_{k} \in T$, let $\nu_{t_{1} \dots t_{k}}$ be a probability measure on $(\mathbb{R}^{n})^{k}$. Suppose that these measures satisfy two consistency conditions: -1. for all permutations $\pi$ of $\{ 1, \dots, k \}$ and measurable sets $F_{i} \subseteq \mathbb{R}^{n}$: - $$\nu_{t_{\pi (1)} \dots t_{\pi (k)}} \left( F_{\pi (1)} \times \dots \times F_{ \pi(k)} \right) = \nu_{t_{1} \dots t_{k}} \left( F_{1} \times \dots \times F_{k} \right);$$测度改变顺序后不变 -2. for all measurable sets $F_{i} \subseteq \mathbb{R}^{n}$,$m \in \mathbb{N}$ : - $$\nu_{t_{1} \dots t_{k}} \left( F_{1} \times \dots \times F_{k} \right) = \nu_{t_{1} \dots t_{k}, t_{k + 1}, \dots , t_{k+m}} \left( F_{1} \times \dots \times F_{k} \times \underbrace{\mathbb{R}^{n} \times \dots \times \mathbb{R}^{n}}_{m} \right).$$ +Let$T$denote some Interval (thought of as "time"), and let$n \in \mathbb{N}$. For each$k \in \mathbb{N}$and finite sequence of distinct times$t_{1}, \dots, t_{k} \in T$, let$\nu_{t_{1} \dots t_{k}}$be a probability measure on$(\mathbb{R}^{n})^{k}$. Suppose that these measures satisfy two consistency conditions: + +1. for all permutations$\pi$of$\{ 1, \dots, k \}$and measurable sets$F_{i} \subseteq \mathbb{R}^{n}$: + $$\nu_{t_{\pi (1)} \dots t_{\pi (k)}} \left( F_{\pi (1)} \times \dots \times F_{ \pi(k)} \right) = \nu_{t_{1} \dots t_{k}} \left( F_{1} \times \dots \times F_{k} \right);$$测度改变顺序后不变 +2. for all measurable sets$F_{i} \subseteq \mathbb{R}^{n}$,$m \in \mathbb{N}$: + $$\nu_{t_{1} \dots t_{k}} \left( F_{1} \times \dots \times F_{k} \right) = \nu_{t_{1} \dots t_{k}, t_{k + 1}, \dots , t_{k+m}} \left( F_{1} \times \dots \times F_{k} \times \underbrace{\mathbb{R}^{n} \times \dots \times \mathbb{R}^{n}}_{m} \right).$$ 可扩展? -Then there exists a probability space $(\Omega, \mathcal{F}, \mathbb{P})$ and a stochastic process $X : T \times \Omega \to \mathbb{R}^{n}$ such that +Then there exists a probability space$(\Omega, \mathcal{F}, \mathbb{P})$and a stochastic process$X : T \times \Omega \to \mathbb{R}^{n}$such that :$\nu_{t_{1} \dots t_{k}} \left( F_{1} \times \dots \times F_{k} \right) = \mathbb{P} \left( X_{t_{1}} \in F_{1}, \dots, X_{t_{k}} \in F_{k} \right)$ -for all $t_{i} \in T$, $k \in \mathbb{N}$ and measurable sets $F_{i} \subseteq \mathbb{R}^{n}$, i.e. $X$ has $\nu_{t_{1} \dots t_{k}}$ as its finite-dimensional distributions relative to times $t_{1} \dots t_{k}$. -In fact, it is always possible to take as the underlying probability space $\Omega = (\mathbb{R}^n)^T$ and to take for $X$ the canonical process $X\colon (t,Y) \mapsto Y_t$. Therefore, an alternative way of stating Kolmogorov's extension theorem is that, provided that the above consistency conditions hold, there exists a (unique) measure $\nu$ on $(\mathbb{R}^n)^T$ with marginals $\nu_{t_{1} \dots t_{k}}$ for any finite collection of times $t_{1} \dots t_{k}$. Kolmogorov's extension theorem applies when $T$ is uncountable, but the price to pay -for this level of generality is that the measure $\nu$ is only defined on the product σ-algebra of $(\mathbb{R}^n)^T$, which is not very rich. +for all$t_{i} \in T$,$k \in \mathbb{N}$and measurable sets$F_{i} \subseteq \mathbb{R}^{n}$, i.e.$X$has$\nu_{t_{1} \dots t_{k}}$as its finite-dimensional distributions relative to times$t_{1} \dots t_{k}$. +In fact, it is always possible to take as the underlying probability space$\Omega = (\mathbb{R}^n)^T$and to take for$X$the canonical process$X\colon (t,Y) \mapsto Y_t$. Therefore, an alternative way of stating Kolmogorov's extension theorem is that, provided that the above consistency conditions hold, there exists a (unique) measure$\nu$on$(\mathbb{R}^n)^T$with marginals$\nu_{t_{1} \dots t_{k}}$for any finite collection of times$t_{1} \dots t_{k}$. Kolmogorov's extension theorem applies when$T$is uncountable, but the price to pay +for this level of generality is that the measure$\nu$is only defined on the product σ-algebra of$(\mathbb{R}^n)^T$, which is not very rich. + # Brownian Motion + ## Definition -A stochastic process $\left\{B_t\right\}_{t \geq 0}$ is called a Brownian motion if it can be constructed as follows: -Fix $x \in \mathbb{R}^n$ and define + +A stochastic process$\left\{B_t\right\}_{t \geq 0}$is called a Brownian motion if it can be constructed as follows: +Fix$x \in \mathbb{R}^n$and define $$ p(t, x, y) = \frac{1}{(2 \pi t)^{n/2}} \exp \left(-\frac{\|x-y\|^2}{2t}\right) $$ -Then if $0 \geq t_1 < t_2 < \cdots < t_k$ define a measure $\mu_{t_1, \cdots, t_k}$ on $\mathbb{R}^{nk}$ by +Then if$0 \geq t_1 < t_2 < \cdots < t_k$define a measure$\mu_{t_1, \cdots, t_k}$on$\mathbb{R}^{nk}$by $$ \mu_{t_1, \cdots, t_k} (F_1 \times \cdots \times F_k) = \int_{F_1 \times \cdots \times F_k} p(t_1, x_0, x_1) p(t_2 - t_1, x_1, x_2) \cdots p(t_k - t_{k-1}, x_{k-1}, x_k) dx_1 \cdots dx_k $$ -where $F_i \in \mathcal{B}(\mathbb{R}^n)$. -Then $\mu_{t_1, \cdots, t_k}$ is a probability measure on $\mathbb{R}^{nk}$ and the finite dimensional distributions of $\left\{B_t\right\}_{t \geq 0}$ are given by +where$F_i \in \mathcal{B}(\mathbb{R}^n)$. +Then$\mu_{t_1, \cdots, t_k}$is a probability measure on$\mathbb{R}^{nk}$and the finite dimensional distributions of$\left\{B_t\right\}_{t \geq 0}$are given by $$ P^x(B_{t_1} \in F_1, \cdots, B_{t_k} \in F_k) = \mu_{t_1, \cdots, t_k} (F_1 \times \cdots \times F_k). $$ We state some basic properties of Brownian motion: -1. $B_t$ is a Gaussian process. -2. $B_t$ has independent increments. -3. \ No newline at end of file + +1.$B_t$is a Gaussian process. +2.$B_t$has independent increments. +3. diff --git "a/Math/Markov \351\223\276\345\237\272\346\234\254\345\256\232\347\220\206.md" "b/Math/Markov \351\223\276\345\237\272\346\234\254\345\256\232\347\220\206.md" index 6080294..b6887c0 100644 --- "a/Math/Markov \351\223\276\345\237\272\346\234\254\345\256\232\347\220\206.md" +++ "b/Math/Markov \351\223\276\345\237\272\346\234\254\345\256\232\347\220\206.md" @@ -4,21 +4,25 @@ documentclass: "ctexart" classoption: "UTF8" --- # Markov 链基本定理 + 当状态$i$是非周期的正常返状态, 则 $$ \lim_{n \to \infty} P_{ii}^{(n)} = \frac{1}{\mu_i}. $$ -Notation: -- $P_{ij}^{(n)}$: 从状态$i$出发, $n$步后到达状态$j$的概率. -- $\mu_i$: 状态$i$的平均重返时间. -- 非周期: $d(i) = 1$. -- 正常返: $f_{ii} = \sum_{n=1}^\infty f_{ii}^{(n)} = 1$. +Notation: + +-$P_{ij}^{(n)}$: 从状态$i$出发,$n$步后到达状态$j$的概率. +-$\mu_i$: 状态$i$的平均重返时间. + +- 非周期:$d(i) = 1$. +- 正常返:$f_{ii} = \sum_{n=1}^\infty f_{ii}^{(n)} = 1$. Proof. | 原函数 | 形式矩母函数 | | -------------- | ------------------------------------------------ | -| $f_{ii}^{(n)}$ | $F_i(t) = \sum_{n=0}^\infty f_{ii}^{(n)} e^{nt}$ | -| $P_{ii}^{(n)}$ | $P_i(t) = \sum_{n=0}^\infty P_{ii}^{(n)} e^{nt}$ | -首先将$P_{ii}^{(n)}$ 分解成若$k$时刻首次返回状态$i$ $(k \leq n)$ 的条件概率求和 +|$f_{ii}^{(n)}$|$F_i(t) = \sum_{n=0}^\infty f_{ii}^{(n)} e^{nt}$| +|$P_{ii}^{(n)}$|$P_i(t) = \sum_{n=0}^\infty P_{ii}^{(n)} e^{nt}$| +首先将$P_{ii}^{(n)}$分解成若$k$时刻首次返回状态$i$$(k \leq n)$的条件概率求和 + $$ P_{ii}^{(n)} = \sum_{k=1}^n f_{ii}^{(k)} P_{ii}^{(n-k)}. $$ @@ -37,4 +41,4 @@ P_i(t) = \frac{1}{1 - F_i(t)} $$ $$ \mu_i = \sum_{n=1}^\infty n f_{ii}^{(n)} = F_i'(0) \\ -P_i(t)/e^{kt} = \sum_{n=0}^\infty P_{ii}^{(n)} e^{(n-k)t} +P_i(t)/e^{kt} = \sum_{n=0}^\infty P_{ii}^{(n)} e^{(n-k)t} diff --git a/Math/SO(3).md b/Math/SO(3).md index 50951d8..35f3392 100644 --- a/Math/SO(3).md +++ b/Math/SO(3).md @@ -4,9 +4,12 @@ documentclass: "ctexart" classoption: "UTF8" --- # SO(3) + ## Quaternion + ### Quaternion basics -Denote the space of quaternions by $\mathbb{H}$, which is a 4-dimensional vector space over $\mathbb{R}$ with basis $\{\mathbf{1}, \mathbf{i}, \mathbf{j}, \mathbf{k}\}$. + +Denote the space of quaternions by$\mathbb{H}$, which is a 4-dimensional vector space over$\mathbb{R}$with basis$\{\mathbf{1}, \mathbf{i}, \mathbf{j}, \mathbf{k}\}$. $$ q = \left(\begin{matrix} a + id & -b-ic \\ b-ic & a-id \end{matrix}\right) = a \mathbf{1} + b \mathbf{i} + c \mathbf{j} + d \mathbf{k} $$ @@ -17,15 +20,20 @@ $$ \bar{q} = a \mathbf{1} - b \mathbf{i} - c \mathbf{j} - d \mathbf{k} |q|^2 = q \bar{q} = \bar{q} q $$ + ## Quaternion and rotation + ### Pure quaternion + $$ p = b \mathbf{i} + c \mathbf{j} + d \mathbf{k} \in \mathbb{R}^3 $$ $$ uv = -u \cdot v + u \times v $$ + ### Unit quaternion + $$ q = \cos \frac{\theta}{2} + \sin \frac{\theta}{2} \mathbf{u} \in \mathbb{S}^3 $$ @@ -40,7 +48,7 @@ q \bar{q} &= (\cos \frac{\theta}{2} + \sin \frac{\theta}{2} \mathbf{u})(\cos \fr \end{aligned} $$ -where $\mathbf{u}$ is a unit vector. +where$\mathbf{u}$is a unit vector. $$ \begin{aligned} q^{-1} &= \bar{q}/|q|^2 \\ @@ -55,7 +63,7 @@ t: \mathbb{R}^3 &\to \mathbb{R}^3 \\ u &\mapsto v=t^{-1} u t \end{aligned} $$ -where $t \in \mathbb{S}^3 \subset \mathbb{H}$. +where$t \in \mathbb{S}^3 \subset \mathbb{H}$. Thus a coresponding is induced $$ \begin{aligned} @@ -63,8 +71,8 @@ T: \mathbb{S}^3 &\to \mathrm{SO}(3) \\ t &\mapsto T_t(\cdot ) = t^{-1} (\cdot) t \end{aligned} $$ -where $T(t)$ is a rotation matrix. -Notice that $T_t = T_{-t}$, and +where$T(t)$is a rotation matrix. +Notice that$T_t = T_{-t}$, and $$ \begin{aligned} T: \mathbb{S}^3 \ \mathrm{mod} \ \{\pm 1\} &\to \mathrm{SO}(3) \\ @@ -79,5 +87,5 @@ $$ ### SO(3) is simple Conjugation can move any vector to any other vector. ### Maximal torus -$ \mathbb{T}^1 $ is a maximal torus of $ \mathrm{SO}(3) $. +$\mathbb{T}^1$is a maximal torus of$\mathrm{SO}(3)$. Since torus has deep connection with diagonalization, maximal torus is also seen as a invariant subspace. diff --git a/Math/answer.md b/Math/answer.md index 0e36873..74d1cf6 100644 --- a/Math/answer.md +++ b/Math/answer.md @@ -4,10 +4,11 @@ documentclass: "ctexart" classoption: "UTF8" --- # answer -Suppose $\sum_{i\in X} x_i$ is convergent, which means $|a - \sum_{i\in \Omega'} x_i| < \epsilon$ for any finite subset $\Omega \subset \Omega' \subset X$. -Consider $\sum_{i\in X} |x_i|$, -$\forall \epsilon > 0$, since $\sum_{i\in X} x_i$ is convergent, there exists a finite subset $\Omega \subset X$ such that $|a - \sum_{i\in \Omega'} x_i| < \epsilon$ for any finite subset $\Omega \subset \Omega' \subset X$. -Note $b = \sum_{i\in \Omega} |x_i|$, then + +Suppose$\sum_{i\in X} x_i$is convergent, which means$|a - \sum_{i\in \Omega'} x_i| < \epsilon$for any finite subset$\Omega \subset \Omega' \subset X$. +Consider$\sum_{i\in X} |x_i|$, +$\forall \epsilon > 0$, since$\sum_{i\in X} x_i$is convergent, there exists a finite subset$\Omega \subset X$such that$|a - \sum_{i\in \Omega'} x_i| < \epsilon$for any finite subset$\Omega \subset \Omega' \subset X$. +Note$b = \sum_{i\in \Omega} |x_i|$, then Consider $$ \begin{aligned} @@ -16,7 +17,7 @@ g: \omega &\mapsto \sum_{i\in \omega} |x_i| \\ \{\Omega' \setminus \Omega &| \Omega \subset \Omega' \subset X\} \to \mathbb{R} \\ \end{aligned} $$ -And since ${x_i}$ is given, $X \setminus \Omega$ can be divided into two subsets $X_1$ and $X_2$ such that $x_i \ge 0$ for $i \in X_1$ and $x_i < 0$ for $i \in X_2$. +And since${x_i}$is given,$X \setminus \Omega$can be divided into two subsets$X_1$and$X_2$such that$x_i \ge 0$for$i \in X_1$and$x_i < 0$for$i \in X_2$. Then define $$ \begin{aligned} @@ -24,11 +25,11 @@ f_+: \omega &\mapsto \sum_{i\in \omega \cap X_1} x_i \\ f_-: \omega &\mapsto \sum_{i\in \omega \cap X_2} |x_i| \\ \end{aligned} $$ -Then $f = f_+ - f_-$ and $g = f_+ + f_-$. -Then one can prove $\sup(2f) \ge \sup(g)$. And then verify +Then$f = f_+ - f_-$and$g = f_+ + f_-$. +Then one can prove$\sup(2f) \ge \sup(g)$. And then verify $$ \begin{aligned} |b - \sup(g)| < 2\epsilon \end{aligned} $$ -Notice: the $b$ part is wrong, since $b$ should not depend on $\Omega$. +Notice: the$b$part is wrong, since$b$should not depend on$\Omega$. diff --git a/Math/graph_laplacian.md b/Math/graph_laplacian.md index 31933cf..895edf2 100644 --- a/Math/graph_laplacian.md +++ b/Math/graph_laplacian.md @@ -4,16 +4,22 @@ documentclass: "ctexart" classoption: "UTF8" --- # Graph Laplacian + ## Definition + The graph Laplacian is a matrix representation of a graph. It is defined as the difference between the degree matrix and the adjacency matrix of the graph. + ## Formula -The graph Laplacian of a graph $G$ with $n$ vertices is defined as: + +The graph Laplacian of a graph$G$with$n$vertices is defined as: $$ L = D - A $$ -where $D$ is the degree matrix and $A$ is the adjacency matrix of the graph. +where$D$is the degree matrix and$A$is the adjacency matrix of the graph. + ## Properties + 1. The graph Laplacian is symmetric and positive semi-definite. 2. The smallest eigenvalue of the graph Laplacian is 0, and the corresponding eigenvector is the all-ones vector. -3. $x^TLx = \frac{1}{2} \sum_{i,j} w_{ij} (x_i - x_j)^2$, where $w_{ij}$ is the weight of the edge between vertices $i$ and $j$. -4. L has $n$ non-negative, real-valued eigenvalues $0 = \lambda_1 \leq \lambda_2 \leq \ldots \leq \lambda_n$. +3.$x^TLx = \frac{1}{2} \sum_{i,j} w_{ij} (x_i - x_j)^2$, where$w_{ij}$is the weight of the edge between vertices$i$and$j$. +4. L has$n$non-negative, real-valued eigenvalues$0 = \lambda_1 \leq \lambda_2 \leq \ldots \leq \lambda_n$. diff --git a/Math/trace.md b/Math/trace.md index ac9b714..458843f 100644 --- a/Math/trace.md +++ b/Math/trace.md @@ -4,43 +4,49 @@ documentclass: "ctexart" classoption: "UTF8" --- # 矩阵的trace + ## Preliminary + ### 行列式求导 (Jacobi's formula) - + $$ \frac{\mathrm{d}}{\mathrm{d}t} \det(A) = \det(A) \text{tr}(A^{-1} \frac{\mathrm{d}A}{\mathrm{d}t}) $$ > **Note:** 证明: -> $$ \frac{\partial \det(A)}{\partial a_{ij} } = A_{ij} $$ -> $A_{ij}$是$A$的代数余子式 -> $$ +>$$\frac{\partial \det(A)}{\partial a_{ij} } = A_{ij}$$ +>$A_{ij}$是$A$的代数余子式 +>$$ > \begin{aligned} > \frac{\mathrm{d}}{\mathrm{d}t} \det(A)&= \sum_{i,j} \frac{\partial}{\partial a_{ij}} \det(A)\frac{\mathrm{d}a_{ij}}{\mathrm{d}t} \\ > &= \sum_{i,j} A_{ij} \frac{\mathrm{d}a_{ij}}{\mathrm{d}t} = \det(A) \sum_{i,j} A_{ij}/\det(A) \frac{\mathrm{d}a_{ij}}{\mathrm{d}t} \\ > &= \det(A) \text{tr}(A^{-1} \frac{\mathrm{d}A}{\mathrm{d}t}) > \end{aligned} -> $$ +>$$ +> ### 行列式和trace的关系 + $$ \det(e^A) = e^{\text{tr}(A)} $$ > **Note:** 证明: -> 考虑 $e^{tA}$,则 -> $$ +> 考虑$e^{tA}$,则 +>$$ > \begin{aligned} > \frac{\mathrm{d}}{\mathrm{d}t} \det(e^{tA}) &= \det(e^{tA}) \text{tr}(e^{-tA} e^{tA} A) \\ > &= \det(e^{tA}) \text{tr}(A) \\ > \end{aligned} -> $$ +>$$ > 两边积分得到 -> $$ +>$$ > \det(e^{tA}) = Ce^{t\text{tr}(A)} -> $$ +>$$ > 代入$t=0$得到$C=I$ > 代入$t=1$得到$\det(e^{A}) = e^{\text{tr}(A)}$ +> ## 矩阵的trace是面积的变化率(一阶近似) + 考虑一个矩阵$A \in \mathbb{R}^{n}$和一个运动 $$ \vec{d}^{i}_t =\vec{d}^{i}_0 + t A \vec{d}^{i}_0 @@ -49,7 +55,7 @@ $$ \det(\vec{d}^{1}_t, \vec{d}^{2}_t, \cdots, \vec{d}^{n}_t) = S_t \\ \det(\vec{d}^{1}_0, \vec{d}^{2}_0, \cdots, \vec{d}^{n}_0) = S_0 $$ -记 $(\vec{d}^{1}_t, \vec{d}^{2}_t, \cdots, \vec{d}^{n}_t)$ 为 $D_t$,$(\vec{d}^{1}_0, \vec{d}^{2}_0, \cdots, \vec{d}^{n}_0)$ 为 $D_0$,则 +记$(\vec{d}^{1}_t, \vec{d}^{2}_t, \cdots, \vec{d}^{n}_t)$为$D_t$,$(\vec{d}^{1}_0, \vec{d}^{2}_0, \cdots, \vec{d}^{n}_0)$为$D_0$,则 $$ \begin{aligned} S_t &= \det(D_0 + t A D_0) \\ @@ -57,17 +63,19 @@ S_t &= \det(D_0 + t A D_0) \\ &=S_{0} + t S_{0} \text{tr}(A) + O(t^2) \end{aligned} $$ + ## 对trace求导 + $$ \frac{\mathrm{d} \mathbf{tr}(AB)}{\mathrm{d}B} = A^T $$ > **Note:** 证明: -> $$ +>$$ > \begin{aligned} > \frac{\mathrm{d} \mathbf{tr}(AB)}{\mathrm{d}B} &= \frac{\mathrm{d} a_{ij} b_{ji}}{\mathrm{d}b_{kl}} \\ > &= a_{ij} \delta_{il} \delta_{jk} \\ > &= a_{lk} \\ > &= A^T > \end{aligned} -> $$ +>$$ diff --git "a/Math/\345\215\225\344\275\215\345\210\206\350\247\243\345\256\232\347\220\206.md" "b/Math/\345\215\225\344\275\215\345\210\206\350\247\243\345\256\232\347\220\206.md" index e6e18c9..30eeae1 100644 --- "a/Math/\345\215\225\344\275\215\345\210\206\350\247\243\345\256\232\347\220\206.md" +++ "b/Math/\345\215\225\344\275\215\345\210\206\350\247\243\345\256\232\347\220\206.md" @@ -4,9 +4,12 @@ documentclass: "ctexart" classoption: "UTF8" --- # 单位分解定理 + ## Basic concepts + ### 拓扑基 + 设$X$是一个拓扑空间,$\mathscr{B}$是$X$的一个子集族,如果$\mathscr{B}$满足: -1. $\mathscr{B}$的元素是$X$的开集 +1.$\mathscr{B}$的元素是$X$的开集 2. 对于$X$的任意开集$U$和任意$x \in U$,存在$B \in \mathscr{B}$,使得$x \in B \subseteq U$ 3. 对于$B_1, B_2 \in \mathscr{B}$和$x \in B_1 \cap B_2$,存在$B_3 \in \mathscr{B}$,使得$x \in B_3 \subseteq B_1 \cap B_2$ diff --git "a/Math/\346\236\201\351\231\220\345\256\232\347\220\206.md" "b/Math/\346\236\201\351\231\220\345\256\232\347\220\206.md" index b816d40..c9046a8 100644 --- "a/Math/\346\236\201\351\231\220\345\256\232\347\220\206.md" +++ "b/Math/\346\236\201\351\231\220\345\256\232\347\220\206.md" @@ -4,16 +4,20 @@ documentclass: "ctexart" classoption: "UTF8" --- # 极限定理 + ## 依概率收敛 + $$ \begin{aligned} \lim_{n \to \infty} P(|X_n - X| > \epsilon) &= 0 \\ \lim_{n \to \infty} P(|X_n - X| \leq \epsilon) &= 1 \end{aligned} $$ + ### Chebyshev 不等式 -If $g(x)$ 是定义在$[0, \infty)$上的非降非负函数, - $Eg(|Y|) < \infty$, then 对任何使$g(a) > 0$的$a > 0$, 有 + +If$g(x)$是定义在$[0, \infty)$上的非降非负函数, + $Eg(|Y|) < \infty$, then 对任何使$g(a) > 0$的$a > 0$, 有 $$ P(|Y| \geq a) \leq \frac{E(|Y|)}{g(a)} $$ diff --git "a/NLP/\345\205\261\347\216\260\346\246\202\347\216\207.md" "b/NLP/\345\205\261\347\216\260\346\246\202\347\216\207.md" index 4e87627..55d77eb 100644 --- "a/NLP/\345\205\261\347\216\260\346\246\202\347\216\207.md" +++ "b/NLP/\345\205\261\347\216\260\346\246\202\347\216\207.md" @@ -4,13 +4,14 @@ documentclass: "ctexart" classoption: "UTF8" --- # 共现概率 -这个式子是约束信息理论共聚类(CITCC)中用来逼近 $p(d_m, v_i)$ 的函数 $q(d_m, v_i)$ 的定义。其中,$\hat{d}_{k_d}$ 和 $\hat{v}_{k_v}$ 是文档和单词的聚类标签(即属于哪个聚类),$k_d$ 和 $k_v$ 分别表示文档和单词的聚类索引。$p\left(\hat{d}_{k_d}, \hat{v}_{k_v}\right)$ 表示文档和单词的聚类的联合概率。$p(d_m \mid \hat{d}_{k_d})$ 表示给定文档聚类标签 $\hat{d}_{k_d}$ 的条件下,文档 $d_m$ 出现的条件概率。$p(v_i \mid \hat{v}_{k_v})$ 表示给定单词聚类标签 $\hat{v}_{k_v}$ 的条件下,单词 $v_i$ 出现的条件概率。该式子的含义是:通过联合文档和单词的聚类标签来计算文档 $d_m$ 和单词 $v_i$ 的共现概率,从而逼近真实的概率分布 $p(d_m, v_i)$。 + +这个式子是约束信息理论共聚类(CITCC)中用来逼近$p(d_m, v_i)$的函数$q(d_m, v_i)$的定义。其中,$\hat{d}_{k_d}$和$\hat{v}_{k_v}$是文档和单词的聚类标签(即属于哪个聚类),$k_d$和$k_v$分别表示文档和单词的聚类索引。$p\left(\hat{d}_{k_d}, \hat{v}_{k_v}\right)$表示文档和单词的聚类的联合概率。$p(d_m \mid \hat{d}_{k_d})$表示给定文档聚类标签$\hat{d}_{k_d}$的条件下,文档$d_m$出现的条件概率。$p(v_i \mid \hat{v}_{k_v})$表示给定单词聚类标签$\hat{v}_{k_v}$的条件下,单词$v_i$出现的条件概率。该式子的含义是:通过联合文档和单词的聚类标签来计算文档$d_m$和单词$v_i$的共现概率,从而逼近真实的概率分布$p(d_m, v_i)$。 Problem Formulation -Denote the document set and word set as $\mathcal{D}=$ $\left\{d_1, d_2, \ldots, d_M\right\}$ and $\mathcal{V}=\left\{v_1, v_2, \ldots, v_V\right\}$. Then the joint probability of $p\left(d_m, v_i\right)$ can be computed based on the cooccurrence count of $d_m$ and $v_i$. For hard clustering problems, shown by Dhillon, Mallela, and Modha (2003), a function +Denote the document set and word set as$\mathcal{D}=$$\left\{d_1, d_2, \ldots, d_M\right\}$and$\mathcal{V}=\left\{v_1, v_2, \ldots, v_V\right\}$. Then the joint probability of$p\left(d_m, v_i\right)$can be computed based on the cooccurrence count of$d_m$and$v_i$. For hard clustering problems, shown by Dhillon, Mallela, and Modha (2003), a function $$ q\left(d_m, v_i\right)=p\left(\hat{d}_{k_d}, \hat{v}_{k_v}\right) p\left(d_m \mid \hat{d}_{k_d}\right) p\left(v_i \mid \hat{v}_{k_v}\right) $$ -where $\hat{d}_{k_d}$ and $\hat{v}_{k_v}$ are cluster indicators, $k_d$ and $k_v$ are the cluster indices, is used to approximate $p\left(d_m, v_i\right)$ by minimizing the Kullback-Leibler (KL) divergence: +where$\hat{d}_{k_d}$and$\hat{v}_{k_v}$are cluster indicators,$k_d$and$k_v$are the cluster indices, is used to approximate$p\left(d_m, v_i\right)$by minimizing the Kullback-Leibler (KL) divergence: $$ \begin{aligned} & D_{K L}(p(\mathcal{D}, \mathcal{V}) \| q(\mathcal{D}, \mathcal{V})) \\ @@ -19,18 +20,18 @@ $$ = & \sum_{k_v}^{K_v} \sum_{v_i: l_{v_i}=k_v} p\left(v_i\right) D_{K L}\left(p\left(\mathcal{D} \mid v_i\right) \| p\left(\mathcal{D} \mid \hat{v}_{k_v}\right)\right) \end{aligned} $$ -where $\hat{\mathcal{D}}$ and $\hat{\mathcal{V}}$ are the cluster sets, $p\left(\mathcal{V} \mid \hat{d}_{k_d}\right)$ denotes a multinomial distribution based on the probabilities $\left.\left(p\left(v_1 \mid \hat{d}_{k_d}\right), \ldots, p\left(v_V \mid \hat{d}_{k_d}\right)\right)^T, \quad p\left(v_i \mid \hat{d}_{k_d}\right)\right)=$ $p\left(v_i \mid \hat{v}_{k_v}\right) p\left(\hat{v}_{k_v} \mid \hat{d}_{k_d}\right)$ and $p\left(v_i \mid \hat{v}_{k_v}\right)=p\left(v_i\right) / p\left(l_{v_i}=\hat{v}_{k_v}\right)$ due to hard clustering labels. Symmetrically we can define the probability for words: $p\left(\mathcal{D} \mid \hat{v}_{k_v}\right)$ denotes a multinomial distribution based on the probabilities $\left.\left(p\left(d_1 \mid \hat{v}_{k_v}\right), \ldots, p\left(d_V \mid \hat{v}_{k_v}\right)\right)^T, \quad p\left(d_i \mid \hat{v}_{k_v}\right)\right)=$ $p\left(d_i \mid \hat{d}_{k_d}\right) p\left(\hat{d}_{k_d} \mid \hat{v}_{k_v}\right)$ and $p\left(d_i \mid \hat{d}_{k_d}\right)=p\left(d_i\right) / p\left(l_{d_i}=\hat{d}_{k_d}\right)$. -这里 $\hat{d}_{k_d}$ 和 $\hat{v}_{k_v}$ 都是指示器变量,用于表示文档和词汇所属的簇。具体来说,$\hat{d}_{k_d}$ 表示第 $k_d$ 个簇,$\hat{v}_{k_v}$ 表示第 $k_v$ 个簇。因此,$\hat{d}_{k_d}$ 和 $\hat{v}_{k_v}$ 的取值为 ${0,1}$,其中 $\hat{d}_{k_d} = 1$ 表示文档 $d_m$ 属于第 $k_d$ 个簇,$\hat{v}_{k_v} = 1$ 表示词汇 $v_i$ 属于第 $k_v$ 个簇。而 $p(\hat{d}_{k_d}, \hat{v}_{k_v})$ 则表示簇 $\hat{d}_{k_d}$ 和 $\hat{v}_{k_v}$ 同时出现的概率。 +where$\hat{\mathcal{D}}$and$\hat{\mathcal{V}}$are the cluster sets,$p\left(\mathcal{V} \mid \hat{d}_{k_d}\right)$denotes a multinomial distribution based on the probabilities$\left.\left(p\left(v_1 \mid \hat{d}_{k_d}\right), \ldots, p\left(v_V \mid \hat{d}_{k_d}\right)\right)^T, \quad p\left(v_i \mid \hat{d}_{k_d}\right)\right)=$$p\left(v_i \mid \hat{v}_{k_v}\right) p\left(\hat{v}_{k_v} \mid \hat{d}_{k_d}\right)$and$p\left(v_i \mid \hat{v}_{k_v}\right)=p\left(v_i\right) / p\left(l_{v_i}=\hat{v}_{k_v}\right)$due to hard clustering labels. Symmetrically we can define the probability for words:$p\left(\mathcal{D} \mid \hat{v}_{k_v}\right)$denotes a multinomial distribution based on the probabilities$\left.\left(p\left(d_1 \mid \hat{v}_{k_v}\right), \ldots, p\left(d_V \mid \hat{v}_{k_v}\right)\right)^T, \quad p\left(d_i \mid \hat{v}_{k_v}\right)\right)=$$p\left(d_i \mid \hat{d}_{k_d}\right) p\left(\hat{d}_{k_d} \mid \hat{v}_{k_v}\right)$and$p\left(d_i \mid \hat{d}_{k_d}\right)=p\left(d_i\right) / p\left(l_{d_i}=\hat{d}_{k_d}\right)$. +这里$\hat{d}_{k_d}$和$\hat{v}_{k_v}$都是指示器变量,用于表示文档和词汇所属的簇。具体来说,$\hat{d}_{k_d}$表示第$k_d$个簇,$\hat{v}_{k_v}$表示第$k_v$个簇。因此,$\hat{d}_{k_d}$和$\hat{v}_{k_v}$的取值为${0,1}$,其中$\hat{d}_{k_d} = 1$表示文档$d_m$属于第$k_d$个簇,$\hat{v}_{k_v} = 1$表示词汇$v_i$属于第$k_v$个簇。而$p(\hat{d}_{k_d}, \hat{v}_{k_v})$则表示簇$\hat{d}_{k_d}$和$\hat{v}_{k_v}$同时出现的概率。 假设我们有两个文档和三个词汇,它们的共现情况如下表所示: | | Word 1 | Word 2 | Word 3 | | --- | --- | --- | --- | | Doc 1 | 2 | 3 | 1 | | Doc 2 | 0 | 1 | 3 | -现在我们要将这些文档和词汇聚类成两个簇。我们可以将 $\hat{d}_{k_d}$ 和 $\hat{v}_{k_v}$ 初始化为随机值。例如,我们可以假设第一个文档属于第一个簇,第二个文档属于第二个簇,第一个词汇属于第一个簇,第二个词汇和第三个词汇属于第二个簇,即: +现在我们要将这些文档和词汇聚类成两个簇。我们可以将$\hat{d}_{k_d}$和$\hat{v}_{k_v}$初始化为随机值。例如,我们可以假设第一个文档属于第一个簇,第二个文档属于第二个簇,第一个词汇属于第一个簇,第二个词汇和第三个词汇属于第二个簇,即: $$ -\hat{d}_{1}=1, \hat{d}_{2}=0, \hat{v}_{1}=1, \hat{v}_{2}=0, \hat{v}_{3}=0 $$ -然后,我们可以使用公式 $q(d_m, v_i) = p(\hat{d}_{k_d}, \hat{v}_{k_v}) p(d_m \mid \hat{d}_{k_d}) p(v_i \mid \hat{v}_{k_v})$ 来计算每个文档和词汇属于每个簇的概率。例如,对于第一个文档和第一个词汇,它们属于第一个簇的概率为: +\hat{d}_{1}=1, \hat{d}_{2}=0, \hat{v}_{1}=1, \hat{v}_{2}=0, \hat{v}_{3}=0$$ +然后,我们可以使用公式$q(d_m, v_i) = p(\hat{d}_{k_d}, \hat{v}_{k_v}) p(d_m \mid \hat{d}_{k_d}) p(v_i \mid \hat{v}_{k_v})$来计算每个文档和词汇属于每个簇的概率。例如,对于第一个文档和第一个词汇,它们属于第一个簇的概率为: $$\begin{aligned} q(d_1, v_1) &= p(\hat{d}_{k_d}, \hat{v}_{k_v}) p(d_m \mid \hat{d}_{k_d}) p(v_i \mid \hat{v}_{k_v}) \\ &= p(\hat{d}_{1}, \hat{v}_{1}) p(d_1 \mid \hat{d}_{1}) p(v_1 \mid \hat{v}_{1}) \\ &= p(\hat{d}_{1}=1, \hat{v}_{1}=1) p(d_1 \mid \hat{d}_{1}=1) p(v_1 \mid \hat{v}_{1}=1) \\ &= ? \times ? \times ? \end{aligned}$$ -其中,$p(\hat{d}_{1}, \hat{v}_{1})$ 表示第一个文档和第一个词汇同时属于第一个簇的概率,$p(d_1 \mid \hat{d}_{1})$ 表示第一个文档属于第一个簇的条件概率,$p(v_1 \mid \hat{v}_{1})$ 表示第一个词汇属于第一个簇的条件概率。这些概率需要根据先前的簇标签和统计信息来计算。 +其中,$p(\hat{d}_{1}, \hat{v}_{1})$表示第一个文档和第一个词汇同时属于第一个簇的概率,$p(d_1 \mid \hat{d}_{1})$表示第一个文档属于第一个簇的条件概率,$p(v_1 \mid \hat{v}_{1})$表示第一个词汇属于第一个簇的条件概率。这些概率需要根据先前的簇标签和统计信息来计算。 这段文字描述了一种基于硬聚类的文档和词汇聚类方法。文档集合和词汇集合分别用$\mathcal{D}$和$\mathcal{V}$表示。根据文档$d_m$和词汇$v_i$的共现次数计算它们的联合概率$p\left(d_m, v_i\right)$。为了解决硬聚类问题,Dhillon, Mallela和Modha(2003)提出了一个函数$q\left(d_m, v_i\right)$来近似$p\left(d_m, v_i\right)$,并通过最小化Kullback-Leibler(KL)散度实现。 -在这个函数中,$\hat{d}_{k_d}$和$\hat{v}_{k_v}$是聚类指示器,而$k_d$和$k_v$是聚类索引。$\hat{\mathcal{D}}$和$\hat{\mathcal{V}}$表示聚类集合。$p\left(\mathcal{V} \mid \hat{d}_{k_d}\right)$表示一个基于概率的多项分布,这些概率由硬聚类标签得出。对于词汇,我们可以对称地定义概率:$p\left(\mathcal{D} \mid \hat{v}_{k_v}\right)$表示一个基于概率的多项分布。 \ No newline at end of file +在这个函数中,$\hat{d}_{k_d}$和$\hat{v}_{k_v}$是聚类指示器,而$k_d$和$k_v$是聚类索引。$\hat{\mathcal{D}}$和$\hat{\mathcal{V}}$表示聚类集合。$p\left(\mathcal{V} \mid \hat{d}_{k_d}\right)$表示一个基于概率的多项分布,这些概率由硬聚类标签得出。对于词汇,我们可以对称地定义概率:$p\left(\mathcal{D} \mid \hat{v}_{k_v}\right)$表示一个基于概率的多项分布。 diff --git a/cocluster_note/Cocluster.md b/cocluster_note/Cocluster.md index a0d35d2..ed8deec 100644 --- a/cocluster_note/Cocluster.md +++ b/cocluster_note/Cocluster.md @@ -4,10 +4,13 @@ documentclass: "ctexart" classoption: "UTF8" --- # Cocluster + ## Cocluster History + 1. 首次出现: 运用于基因表达数据的聚类算法, Cheng & Church (2000) [^cheng2000BiclusteringExpressionData], 使用方均 residuals 作为度量, 找到所有 mannually selected 的 thereshold 以下的子矩阵. 2. Spectral Co-clustering: 该算法使用了一种基于谱聚类的方法, SCC [^dhillon2001CoclusteringDocumentsWordsa]. 该算法 coclusters on word-document matrix, 使用了一个基于谱聚类的方法, 它将数据矩阵转换为一个二分图, 最小化边权重来 partition. 于是有了三种: + - Graph theory [^kluger2003SpectralBiclusteringMicroarray][^sun2014BiforceLargescaleBicluster] - Statistical model [^dhillon2003InformationtheoreticCoclustering][^govaert2003ClusteringBlockMixturea][^govaert2005EMAlgorithmBlock][^govaert2008BlockClusteringBernoullia][^shan2008BayesianCoclusteringd] - Matrix factorization [^gu2009CoclusteringManifoldsc] [^labiod2015UnifiedFrameworkDatac] [^liu2014NetworkassistedCoclusteringAlgorithmc][^madeira2004BiclusteringAlgorithmsBiological] [^salah2018WordCooccurrenceRegularizeda][^wang2011FastNonnegativeMatrix] [^wang2017PenalizedNonnegativeMatrixc] [^yu2017NetworkaidedBiClusteringDiscovering] @@ -21,15 +24,19 @@ classoption: "UTF8" - Text mining - Bioinformatics - Recommendation system [^vizinepereira2015SimultaneousCoclusteringLearninga] + ## 优点 - 与传统聚类算法相比, coclustering 能够发现数据中的子空间, 即子矩阵, 这些子矩阵可能在不同的特征子集中嵌入, 不同的特征可能对不同的聚类有意义. 在特征空间中全局操作的算法无法发现这种局部模式. + ## Evaluation Score + - variance - maximum interaction criterion [^bock2016ProbabilisticTwowayClustering] - mean-square residue [^cheng2000BiclusteringExpressionData] - scaling mean-square residue [^mukhopadhyay2009NovelCoherenceMeasurec] - average correlation value [^teng2008DiscoveringBiclustersIterativelyc] + [^cheng2000BiclusteringExpressionData]: Cheng, Y., & Church, G. (2000). Biclustering of Expression Data. Proceedings. International Conference on Intelligent Systems for Molecular Biology. [^dhillon2001CoclusteringDocumentsWordsa]: Dhillon, I. S. (2001). Co-clustering documents and words using bipartite spectral graph partitioning. ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, 269–274. [^vizinepereira2015SimultaneousCoclusteringLearninga]: Vizine Pereira, A. L., & Hruschka, E. R. (2015). Simultaneous co-clustering and learning to address the cold start problem in recommender systems. Knowledge-Based Systems, 82, 11–19. @@ -61,73 +68,84 @@ classoption: "UTF8" [^NIPS2017_00a03ec6]: Nie, F., Wang, X., Deng, C., & Huang, H. (2017). Learning a structured optimal bipartite graph for co-clustering. In I. Guyon, U. V. Luxburg, S. Bengio, H. Wallach, R. Fergus, S. Vishwanathan, & R. Garnett (Eds.), Advances in neural information processing systems (Vol. 30). Curran Associates, Inc. [^ding2006OrthogonalNonnegativeMatrix]: Ding, C., Li, T., Peng, W., & Park, H. (2006). Orthogonal nonnegative matrix t-factorizations for clustering. Proceedings of the 12th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, 126–135. [^long2005CoclusteringBlockValue]: Long, B., Zhang, Z. (Mark), & Yu, P. S. (2005). Co-clustering by block value decomposition. Knowledge Discovery and Data Mining, 635–640. + ## Spectral clustering + - 通过谱聚类的方法, 将数据矩阵转换为一个二分图, 最小化边权重来 partition. -- Data matrix: $B \in \mathbb{R}^{n \times m}$, $n$ 为行数, $m$ 为列数. -- $$ A = \begin{bmatrix} 0 & B \\ B^T & 0 \end{bmatrix} $$ -- $ N = n + m $, 是 $A$ 的维度. -- $ D = \text{diag}(A \mathbf{1}) $, 是 $A$ 的度矩阵. -- $ d_{ii} = \sum_{j=1}^{N} a_{ij} $ -- $ d_{ij} = \delta_{ij} a_{ik} \mathbf{1}_k $ -- $ L = D - A \in \mathbb{R}^{N \times N} $, 是拉普拉斯矩阵. -- $ l_{ij} = \delta_{ij} a_{ik} \mathbf{1}_k - a_{ij} $ ($l_{jk} = \delta_{jk} a_{jl} \mathbf{1}_l - a_{jk}$) -- $ Y \in \mathbb{R}^{N \times k} $, 是 $k$ 个特征向量组成的矩阵. -- 取 $Y$ 的第 $j$ 列作为 $y_j$, $y_j^\top D y_j = \lambda_j$ 是 clustering $j$ 的 associate degree. -- $ y_j^\top A y_j $ 是 clustering $j$ 内部的度. -- $ y_j^\top L y_j = \lambda_j - y_j^\top A y_j $ 是 clustering $j$ 的度. +- Data matrix:$B \in \mathbb{R}^{n \times m}$,$n$为行数,$m$为列数. +-$$A = \begin{bmatrix} 0 & B \\ B^T & 0 \end{bmatrix}$$ +-$N = n + m$, 是$A$的维度. +-$D = \text{diag}(A \mathbf{1})$, 是$A$的度矩阵. +-$d_{ii} = \sum_{j=1}^{N} a_{ij}$ +-$d_{ij} = \delta_{ij} a_{ik} \mathbf{1}_k$ +-$L = D - A \in \mathbb{R}^{N \times N}$, 是拉普拉斯矩阵. +-$l_{ij} = \delta_{ij} a_{ik} \mathbf{1}_k - a_{ij}$($l_{jk} = \delta_{jk} a_{jl} \mathbf{1}_l - a_{jk}$) +-$Y \in \mathbb{R}^{N \times k}$, 是$k$个特征向量组成的矩阵. +- 取$Y$的第$j$列作为$y_j$,$y_j^\top D y_j = \lambda_j$是 clustering$j$的 associate degree. +-$y_j^\top A y_j$是 clustering$j$内部的度. +-$y_j^\top L y_j = \lambda_j - y_j^\top A y_j$是 clustering$j$的度. + ### Theorem -$$ \sum_{j=1}^{k} \frac{y_j^\top L y_j}{y_j^\top D y_j} = \mathrm{Tr} (Z^\top L Z) $$ + +$$\sum_{j=1}^{k} \frac{y_j^\top L y_j}{y_j^\top D y_j} = \mathrm{Tr} (Z^\top L Z)$$ 于是优化目标成为 -$$ \min_{Z^\top D Z = I} \mathrm{Tr} (Z^\top L Z) $$ -其中 $ Z = Y(Y^\top D Y)^{-\frac{1}{2}}. $ +$$\min_{Z^\top D Z = I} \mathrm{Tr} (Z^\top L Z)$$ +其中$Z = Y(Y^\top D Y)^{-\frac{1}{2}}.$ 如果记 -- $F = D^{-\frac{1}{2}} Z$, -- $F^\top = [U^\top, V^\top]$, -- $D = \text{diag}(D_u, D_v)$, -则记 $ O = U^\top D_u^{\frac{1}{2}} B D_v^{\frac{1}{2}} V $ + +-$F = D^{-\frac{1}{2}} Z$, +-$F^\top = [U^\top, V^\top]$, +-$D = \text{diag}(D_u, D_v)$, +则记$O = U^\top D_u^{\frac{1}{2}} B D_v^{\frac{1}{2}} V$ 优化目标成为 + $$ \begin{equation} \max_{U^\top U + V^\top V = I} \mathrm{Tr} (O) \end{equation} $$ + ### Proof -- $ D' = Y^\top D Y $, 可以证明是对角矩阵, 对角元素是 $ \lambda_i $. -- $ L' = Y^\top L Y $ -- $ Z = Y(D')^{-\frac{1}{2}} $ + +-$D' = Y^\top D Y$, 可以证明是对角矩阵, 对角元素是$\lambda_i$. +-$L' = Y^\top L Y$ +-$Z = Y(D')^{-\frac{1}{2}}$ + $$ \begin{array}{ll} \mathrm{Tr} (Z^\top L Z) &= \mathrm{Tr}[(Y(D')^{-\frac{1}{2}})^\top L Y(D')^{-\frac{1}{2}}] \\ &= \mathrm{Tr}(L' (D')^{-1}) \\ \end{array} $$ -先算一下 $l'_{ii}$: +先算一下$l'_{ii}$: $$ \begin{array}{ll} l'_{ii} &= y_{ki} (l_{kj}) y_{kj} \\ &= y_i^\top L y_i \\ \end{array} $$ -由于 $ D' $ 是对角矩阵, 所以 $ (D')^{-1} $ 也是对角矩阵, 所以 +由于$D'$是对角矩阵, 所以$(D')^{-1}$也是对角矩阵, 所以 $$ \begin{array}{ll} \mathrm{Tr} (Z^\top L Z) &= \sum_{i=1}^{N} \frac{l'_{ii}}{d'_{ii}} \\ &= \sum_{i=1}^{N} \cfrac{y_i^\top L y_i}{y_i^\top D y_i} \end{array} $$ -检查一下 $Z^\top D Z = I$ 需要 $Y$ 满足什么条件. 其实就是 $Y^\top D Y$ 可以进行 $-\frac{1}{2}$ 次方操作. 也就是说 $Y^\top D Y$ 必须是正定矩阵. 这要求 $Y$ 是列满秩的, 也就是说没有两个线性相关的聚类. -因为 $Y^\top D Y$ 正定等价于 $ \forall x \neq 0, x^\top Y^\top D Y x = (Yx)^\top D (Yx) > 0 $. 记 $ z = Yx $, 则 $ x^\top Y^\top D Y x = z^\top D z > 0 $, 所以只需 $x \neq 0$ 时有 $z \neq 0$ 即可. +检查一下$Z^\top D Z = I$需要$Y$满足什么条件. 其实就是$Y^\top D Y$可以进行$-\frac{1}{2}$次方操作. 也就是说$Y^\top D Y$必须是正定矩阵. 这要求$Y$是列满秩的, 也就是说没有两个线性相关的聚类. +因为$Y^\top D Y$正定等价于$\forall x \neq 0, x^\top Y^\top D Y x = (Yx)^\top D (Yx) > 0$. 记$z = Yx$, 则$x^\top Y^\top D Y x = z^\top D z > 0$, 所以只需$x \neq 0$时有$z \neq 0$即可. 而 -$$ Z^\top L Z = I - O - O^\top $$ -$$ Z^\top D Z = U^\top U + V^\top V = I $$ +$$Z^\top L Z = I - O - O^\top$$ +$$Z^\top D Z = U^\top U + V^\top V = I$$ 则直接计算有 -$$ \begin{equation}\max_{U^\top U + V^\top V = I} \mathrm{Tr} (O)\end{equation} $$ +$$\begin{equation}\max_{U^\top U + V^\top V = I} \mathrm{Tr} (O)\end{equation}$$ + ### Lemma 连续情况的优化 + 优化目标 $$ \max_{X^\top X + Y^\top Y = I} \mathrm{Tr} (X^\top M Y), $$ -其中 $M \in \mathbb{R}^{n_1 \times n_2}$, $X \in \mathbb{R}^{n_1 \times k}$, $Y \in \mathbb{R}^{n_2 \times k}$. +其中$M \in \mathbb{R}^{n_1 \times n_2}$,$X \in \mathbb{R}^{n_1 \times k}$,$Y \in \mathbb{R}^{n_2 \times k}$. 那么其解为 $$ \begin{equation} @@ -137,28 +155,31 @@ Y = \frac{\sqrt{2}}{2} V_1 \end{cases} \end{equation} $$ -其中, $U_1$ 和 $V_1$ 是 $M$ 前 $k$ 个最大的奇异值对应的左右奇异向量. +其中,$U_1$和$V_1$是$M$前$k$个最大的奇异值对应的左右奇异向量. > Proof: -> 拉格朗日函数 $\mathcal{L} = \mathrm{Tr} (X^\top M Y) - \mathrm{Tr} (\frac{1}{2}\Lambda (X^\top X + Y^\top Y - I))$. +> 拉格朗日函数$\mathcal{L} = \mathrm{Tr} (X^\top M Y) - \mathrm{Tr} (\frac{1}{2}\Lambda (X^\top X + Y^\top Y - I))$. > -> $$\mathcal{L} = x_{ji} m_{jk} y_{ki} - \lambda_{ij} x_{kj} x_{ki} - \frac{1}{2}\lambda_{ij} y_{kj} y_{ki} - \frac{1}{2}\lambda_{ij} \lambda_{ij}. $$ +>$$\mathcal{L} = x_{ji} m_{jk} y_{ki} - \lambda_{ij} x_{kj} x_{ki} - \frac{1}{2}\lambda_{ij} y_{kj} y_{ki} - \frac{1}{2}\lambda_{ij} \lambda_{ij}.$$ > -> $$ +>$$ > \begin{aligned} > 0 = \frac{\partial \mathcal{L}}{\partial x_{ab}} &= m_{ak} y_{kb} - \lambda_{ij} \frac{\partial x_{kj} x_{ki}}{\partial x_{ab}} =MY - X\Lambda \\ > 0 = \frac{\partial \mathcal{L}}{\partial y_{ab}} &= m_{ka} x_{bk} - \lambda_{ij} \frac{\partial y_{kj} y_{ki}}{\partial y_{ab}} =M^\top X - Y\Lambda > \end{aligned} -> $$ +>$$ > -> $$ +>$$ > \begin{aligned} > M M^\top (X_1, X_2, \cdots, X_k) &= M M^\top X = M Y \Lambda = X \Lambda^2 \\ > &= X \text{diag}(\lambda_1^2, \lambda_2^2, \cdots, \lambda_k^2) = (\lambda_1^2 X_1, \lambda_2^2 X_2, \cdots, \lambda_k^2 X_k) > \end{aligned} -> $$ +>$$ +> +> 于是$X$是$M$的前$k$个最大的奇异值对应的左奇异向量. +> 同理可得$Y$是$M$的前$k$个最大的奇异值对应的右奇异向量. > -> 于是 $X$ 是 $M$ 的前 $k$ 个最大的奇异值对应的左奇异向量. -> 同理可得 $Y$ 是 $M$ 的前 $k$ 个最大的奇异值对应的右奇异向量. ### 离散情况 + ## Conclusion + ## References diff --git a/git-credential-manager b/git-credential-manager deleted file mode 160000 index 6904af7..0000000 --- a/git-credential-manager +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 6904af78ef15c09a86ae49f98bb1fc4651e49e32 diff --git a/latex/crefname.md b/latex/crefname.md index 8e41c63..e812554 100644 --- a/latex/crefname.md +++ b/latex/crefname.md @@ -4,18 +4,26 @@ documentclass: "ctexart" classoption: "UTF8" --- # LaTeX 自定义 Lemma 引用及计数器使用指南 + 在 LaTeX 中,如果希望引用 `lemma` 环境并且使用计数器,同时确保在引用时显示为“Lemma”而不是“Theorem”,可以按照以下步骤操作: + ## 步骤 1:定义定理环境 + 首先,定义定理环境,并确保 `lemma` 环境继承 `theorem` 的计数器: + ```latex \newtheorem{theorem}{Theorem} \newtheorem{lemma}[theorem]{Lemma} % 继承 theorem 的计数器 \newtheorem{definition}[theorem]{Definition} \newtheorem{assumption}[theorem]{Assumption} ``` + **注意**: `\newtheorem{lemma}[theorem]{Lemma}` 中的 `[theorem]` 是导致 `crefname` 没有更新的元凶。这意味着 `lemma` 使用了 `theorem` 的计数器,这会让 `cleveref` 误认为 `lemma` 是 `theorem`。 + ## 步骤 2:加载所需包 + 加载 `hyperref` 和 `cleveref` 包,并自定义引用名称: + ```latex % 先加载 hyperref \usepackage{hyperref} @@ -31,14 +39,20 @@ classoption: "UTF8" \crefname{assumption}{Assumption}{Assumptions} \Crefname{assumption}{Assumption}{Assumptions} ``` + ## 步骤 3:自定义引用命令 + 为了确保引用 `lemma` 时显示为“Lemma”而不是“Theorem”,可以创建一个自定义的引用命令: + ```latex % 自定义 Lemma 引用命令 \newcommand{\lemmaref}[1]{Lemma~\ref{#1}} ``` + ## 步骤 4:修复 crefname 问题 + 如果希望继续使用 `theorem` 的计数器但引用名称正确,可以通过以下步骤操作: + ```latex \usepackage{aliascnt} % 定理环境的定义 @@ -53,8 +67,11 @@ classoption: "UTF8" \crefname{lemma}{Lemma}{Lemmas} \Crefname{lemma}{Lemma}{Lemmas} ``` + ## 步骤 5:示例代码 + 以下是一个完整的示例代码,演示如何实现这一目标: + ```latex \documentclass{article} % 其他需要的包 @@ -80,13 +97,14 @@ classoption: "UTF8" \begin{document} \begin{lemma}[Joint Probability of Co-cluster Size] \label{lem:joint_probability} - Let $C_k$ be a co-cluster and $B_{(i,j)}$ be a block in the partitioned matrix. The probability that the size of the co-cluster $C_k$ within block $B_{(i,j)}$ is less than $T_m$ rows and $T_n$ columns is given by: + Let$C_k$be a co-cluster and$B_{(i,j)}$be a block in the partitioned matrix. The probability that the size of the co-cluster$C_k$within block$B_{(i,j)}$is less than$T_m$rows and$T_n$columns is given by: \begin{aligned} P(M_{(i,j)}^{(k)} < T_m, N_{(i,j)}^{(k)} < T_n) & \le \exp[-2 (s_i^{(k)})^2 \phi_i -2 (t_j^{(k)})^2 \psi_j] \end{aligned} - where $s_i^{(k)} = \cfrac{M^{(k)}}{M}-\cfrac{T_m-1}{\phi_i}$ and $t_j^{(k)} = \cfrac{N^{(k)}}{N}-\cfrac{T_n-1}{\psi_j}$. + where$s_i^{(k)} = \cfrac{M^{(k)}}{M}-\cfrac{T_m-1}{\phi_i}$and$t_j^{(k)} = \cfrac{N^{(k)}}{N}-\cfrac{T_n-1}{\psi_j}$. \end{lemma} -In the scenario where the matrix $A$ is partitioned into $m \times n$ blocks, each block has size $\phi_i \times $\psi_j$, that is, $M=\sum_{i=1}^m \phi_i$ and $N=\sum_{j=1}^n \psi_j$, the joint probability of $M_{(i,j)}^{(k)}$ and $N_{(i,j)}^{(k)}$ is given by \lemmaref{lem:joint_probability}. +In the scenario where the matrix$A$is partitioned into$m \times n$blocks, each block has size$\phi_i \times$\psi_j$, that is,$M=\sum_{i=1}^m \phi_i$and$N=\sum_{j=1}^n \psi_j$, the joint probability of$M_{(i,j)}^{(k)}$and$N_{(i,j)}^{(k)}$is given by \lemmaref{lem:joint_probability}. \end{document} ``` + 通过以上步骤,您可以确保在引用 `lemma` 时显示为“Lemma”而不是“Theorem”,同时保持计数器的一致性。 diff --git a/subfile_latexdiff/index.md b/subfile_latexdiff/index.md index 96d5fd9..85cf95d 100644 --- a/subfile_latexdiff/index.md +++ b/subfile_latexdiff/index.md @@ -4,6 +4,7 @@ documentclass: "ctexart" classoption: "UTF8" --- # Latexdiff with subfiles - TeX - LaTeX Stack Exchange --- 带有子文件的 Latexdiff - TeX - LaTeX 堆栈交换 + Latexdiff with subfiles 带有子文件的 Latexdiff Ask Question Is there a way to make latexdiff work with the 'subfiles' package ? @@ -16,6 +17,7 @@ Example : ****dd 例: main.tex + ```latex \documentclass[10pt]{article} \usepackage{subfiles} @@ -23,21 +25,27 @@ main.tex \subfile{includeme.tex} \end{document} ``` + includeme.tex 包括我.tex + ```latex \documentclass[main.tex]{subfiles} \begin{document} Text! \end{document} ``` + Running 运行 + ```latex latexdiff d1/main.tex d2/main.tex --flatten > mydiff.tex ``` + the resulting document simply does not include the contents of the subfile. 生成的文档根本不包含子文件的内容。 mydiff.tex + ```latex \documentclass[10pt]{article} %DIF LATEXDIFF DIFFERENCE FILE @@ -47,6 +55,7 @@ mydiff.tex \subfile{includeme.tex} \end{document} ``` + So yes, the problem lies with the flatten pipeline/workflow, which does not seem to be made to work with \\subfile{includeme.tex} includes. 所以是的,问题出在扁平化的管道/工作流上,它似乎不适用于 `\subfile{includeme.tex}` 包含。 You could try some of the `flatten` alternatives discussed here: [tex.stackexchange.com/questions/21838/…](http://tex.stackexchange.com/questions/21838/replace-inputfilex-by-the-content-of-filex-automatically "replace inputfilex by the content of filex automatically") @@ -70,7 +79,9 @@ _For posterity:_ at least as of `latexdiff version 1.1.1`, using the `--flatten` – [DilithiumMatrix](https://tex.stackexchange.com/users/22806/dilithiummatrix "595 reputation") [Jun 1, 2017 at 12:58](#comment921132_167620) [Show **1** more comment](# "Expand to show all comments on this post") + ## 3 Answers + Sorted by: Highest score (default) Date modified (newest first) Date created (oldest first) 8 @@ -86,7 +97,7 @@ The -p option forces latexdiff to omit the preamble commands that it normally in \-p 选项强制 latexdiff 省略它通常在找到 \\begin{document} 时自动插入的前导码命令(需要辅助文件“null”,因为由于 latexdiff 中的错误无法识别 -p/dev/null)。 Now all that remains is to automate this. The following line is a hacky way to achieve some automation as proof-of-concept but would really need to be expanded into a more robust and flexible small shell script: 现在剩下的就是自动化。以下行是实现一些自动化作为概念验证的黑客方法,但实际上需要扩展为更强大、更灵活的小 shell 脚本: -`grep -v '^%' main.tex | grep subfile\{ | sed 's/^.*subfile{\(.*\)}.*$/\1/' \ | awk '{ print "latexdiff -pnull d1/" $1, "d2/" $1,">", $1 }' | sh` +`grep -v '^%' main.tex | grep subfile\{ | sed 's/^.*subfile{\(.*\)}.*$/\1/' \ | awk '{ print "latexdiff -pnull d1/"$1, "d2/"$1,">",$1 }' | sh` I have noted the OP question as a feature request and eventually the --flatten option of latexdiff might be updated to deal with this 'natively'. The 'null' file workaround will probably not be necessary from version 1.0.4 onwards (not yet released at the time of writing) 我已将 OP 问题作为功能请求,最终 latexdiff 的 --flatten 选项可能会更新以“原生”处理此问题。从 1.0.4 版开始(撰写本文时尚未发布)可能不需要“null”文件解决方法 – [frederik](https://tex.stackexchange.com/users/38437/frederik "1,375 reputation") @@ -103,6 +114,7 @@ Note that latexdiff version 1.0.4 is now released and --flatten supports \\subfi @frederik 如果子文件位于使用 `\def\input@path{{./tex/} {./} {../}}` . 2 years after the question was asked, but I ended up writing a batch file for solving this in a windows environment: 在提出这个问题 2 年后,但我最终编写了一个批处理文件来在 Windows 环境中解决这个问题: + ```latex @echo off setlocal @@ -117,8 +129,10 @@ latexdiff --flatten %old_path%flat.tex flat.tex > diff.tex rm flat.tex rm %old_path%flat.tex ``` + Post above [link](https://tex.stackexchange.com/a/346316/243072) was very helpful, but I made my modified version that you can use. 上面的链接非常有帮助,但我制作了您可以使用的修改版本。 + ```latex @echo off setlocal