Skill 寫法圖鑑

algo-social-virality

asgard-ai-platform | 行銷與 SEO | 原文 | MIT

用 SIR 傳染病模型預測內容的病毒式擴散

中文翻譯

---
name: "algo-social-virality"
description: "用 SIR/SIS/SEIR 區室模型(compartmental models)建模病毒式擴散的動態。當使用者需要預測內容的擴散模式、估計爆紅的門檻、或建模社群網路中的資訊級聯時使用,即使他們說的是「這會爆紅嗎」、「內容的傳染病模型」或「擴散預測」也一樣。"
metadata:
  category: "WP-38 社群演算法"
  tags: ["social-media", "virality", "epidemic-model", "sir"]
---

# 病毒式擴散模型(Viral Spread Models)

## 概述

區室模型(SIR、SIS、SEIR)模擬內容/資訊如何在族群中擴散。易感者 → 感染者 → 康復者,對應到不知情 → 正在分享 → 不再分享。關鍵指標:R0(基本再生數)。以 ODE 求解,複雜度 O(T × N),T 是時間步數,N 是區室數。

## 何時使用

**觸發條件:**
- 要建模內容如何在社群網路中擴散
- 要估計一個活動能不能達到爆紅的門檻
- 要事後分析爆紅事件的擴散動態

**何時不要用:**
- 要預測個別使用者的行為時(用影響力評分)
- 要衡量互動指標時(用互動率計算器)

## 演算法

```
鐵律:只有在 R0 > 1 時,才會有病毒式擴散
R0 = 傳播率(β)/ 康復率(γ)。
R0 低於 1 時,不論初始種子多大,內容都會消失。
R0 高於 1 時,在飽和之前會進入指數成長階段。
要設計介入手段(播種、誘因),把 R0 推過門檻。
```

### 階段 1:輸入驗證
定義:族群大小(N)、初始種子數(I₀)、傳播率(β,接觸後分享的機率)、康復率(γ,失去興趣的速率)。
**關卡:** 參數非負、β 和 γ 是從歷史資料估計或假設出來的。

### 階段 2:核心演算法
**SIR 模型:** dS/dt = -βSI/N、dI/dt = βSI/N - γI、dR/dt = γI
1. 初始化:S=N-I₀、I=I₀、R=0
2. 在離散的時間步上,用 Euler 法或 RK4 迭代
3. 追蹤感染的高峰(同時分享者的最大值)和累計被感染的總數

**SIS 變體:** 不會進入免疫的康復狀態,康復者會再次變成易感者(會重複出現的內容)。

### 階段 3:驗證
檢查:在所有時間步上,S+I+R = N(守恆)。高峰和最終規模,對給定的 R0 而言是合理的。
**關卡:** 族群守恆、動態和 R0 一致。

### 階段 4:輸出
回傳各區室的時間序列和摘要指標。

## 輸出格式

```json
{
  "time_series": [{"t": 0, "S": 9900, "I": 100, "R": 0}],
  "summary": {"R0": 2.5, "peak_infected": 3200, "peak_day": 12, "total_infected": 8500},
  "metadata": {"model": "SIR", "beta": 0.5, "gamma": 0.2, "population": 10000}
}
```

## 範例

### 輸入輸出範例
**輸入:** N=10000、I₀=10、β=0.3、γ=0.1(R0=3.0)
**預期:** 指數成長,第 15 天左右達到高峰約 4000,累計感染約 9500

### 邊界情況
| 輸入 | 預期 | 原因 |
|-------|----------|-----|
| R0 = 0.8 | 快速衰減 | 低於門檻,會消失 |
| I₀ = 1 | 起步較慢,但最終動態相同 | 單一種子需要更久才會點燃 |
| β = γ(R0=1) | 線性,沒有成長 | 臨界門檻,地方流行的平衡 |

## 常見陷阱

- **均勻混合假設**:SIR 假設每個人的互動程度都一樣。真實網路有樞紐、群集和弱連結。要更貼近現實,用以網路為基礎的模型。
- **參數估計**:社群內容的 β 和 γ 很難估計。用早期的擴散資料擬合參數,再往後推估。
- **內容 ≠ 疾病**:和疾病不同,內容分享是自願的,並受內容品質、平台演算法和趨勢影響。模型給的是粗略的動態,不是精準的預測。
- **平台演算法**:社群媒體的演算法會放大或壓制內容。「傳播率」有一部分是由平台決定的,不只是使用者的行為。
- **時間動態**:內容爆紅的生命週期,通常比疾病短得多(數小時到數天,對比數週到數月)。時間尺度要相應調整。

## 參考資料

- 以網路為基礎的傳染病模型,見 `references/network-sir.md`
- 從早期資料估計參數,見 `references/parameter-fitting.md`

英文原文

---
name: "algo-social-virality"
description: "Model viral spread dynamics using SIR/SIS/SEIR compartmental models. Use this skill when the user needs to predict content spread patterns, estimate viral thresholds, or model information cascades in social networks — even if they say 'will this go viral', 'epidemic model for content', or 'spread prediction'."
metadata:
  category: "WP-38 社群演算法"
  tags: ["social-media", "virality", "epidemic-model", "sir"]
---

# Viral Spread Models

## Overview

Compartmental models (SIR, SIS, SEIR) model how content/information spreads through populations. Susceptible → Infected → Recovered mirrors unaware → sharing → stopped sharing. Key metric: R0 (basic reproduction number). Solves as ODEs in O(T × N) for T timesteps, N compartments.

## When to Use

**Trigger conditions:**
- Modeling how content spreads through a social network
- Estimating whether a campaign will achieve viral threshold
- Analyzing post-hoc spread dynamics of viral events

**When NOT to use:**
- When predicting individual user behavior (use influence scoring)
- When measuring engagement metrics (use engagement rate calculator)

## Algorithm

```
IRON LAW: Viral Spread Occurs ONLY When R0 > 1
R0 = transmission rate (β) / recovery rate (γ).
Below R0 = 1, content dies out regardless of initial seed size.
Above R0 = 1, exponential growth phase begins before saturation.
Design interventions (seeding, incentives) to push R0 above threshold.
```

### Phase 1: Input Validation
Define: population size (N), initial seed size (I₀), transmission rate (β — probability of sharing upon exposure), recovery rate (γ — rate of losing interest).
**Gate:** Parameters non-negative, β and γ estimated from historical data or assumed.

### Phase 2: Core Algorithm
**SIR Model:** dS/dt = -βSI/N, dI/dt = βSI/N - γI, dR/dt = γI
1. Initialize: S=N-I₀, I=I₀, R=0
2. Iterate using Euler method or RK4 at discrete timesteps
3. Track peak infected (maximum simultaneous sharers) and total ever-infected

**SIS variant:** No recovery to immune state — recovered become susceptible again (recurring content).

### Phase 3: Verification
Check: S+I+R = N at all timesteps (conservation). Peak and final sizes plausible for given R0.
**Gate:** Population conserved, dynamics consistent with R0.

### Phase 4: Output
Return time series of compartments and summary metrics.

## Output Format

```json
{
  "time_series": [{"t": 0, "S": 9900, "I": 100, "R": 0}],
  "summary": {"R0": 2.5, "peak_infected": 3200, "peak_day": 12, "total_infected": 8500},
  "metadata": {"model": "SIR", "beta": 0.5, "gamma": 0.2, "population": 10000}
}
```

## Examples

### Sample I/O
**Input:** N=10000, I₀=10, β=0.3, γ=0.1 (R0=3.0)
**Expected:** Exponential growth, peak ~4000 at day ~15, total infected ~9500

### Edge Cases
| Input | Expected | Why |
|-------|----------|-----|
| R0 = 0.8 | Rapid decay | Below threshold, dies out |
| I₀ = 1 | Slower start but same eventual dynamics | Single seed takes longer to ignite |
| β = γ (R0=1) | Linear, no growth | Critical threshold, endemic equilibrium |

## Gotchas

- **Homogeneous mixing assumption**: SIR assumes everyone interacts equally. Real networks have hubs, clusters, and weak ties. Use network-based models for realistic spread.
- **Parameter estimation**: β and γ are hard to estimate for social content. Use early spread data to fit parameters, then project.
- **Content ≠ disease**: Unlike diseases, content sharing is voluntary and influenced by content quality, platform algorithms, and trends. Models give rough dynamics, not precise predictions.
- **Platform algorithms**: Social media algorithms amplify or suppress content. The "transmission rate" is partly determined by the platform, not just user behavior.
- **Temporal dynamics**: Content virality often has a much shorter lifecycle than disease (hours-days vs weeks-months). Adjust timescales accordingly.

## References

- For network-based epidemic models, see `references/network-sir.md`
- For parameter estimation from early data, see `references/parameter-fitting.md`