Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .translate/state/scipy.md.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source-sha: cfedc1a06bbefe20d23924d26aef437a968ab2da
synced-at: "2026-03-20"
source-sha: fb75a07e49cbec97c2c3e698a81ee008203b1fab
synced-at: "2026-05-08"
model: claude-sonnet-4-6
mode: NEW
mode: UPDATE
section-count: 8
tool-version: 0.13.1
tool-version: 0.14.1
20 changes: 11 additions & 9 deletions lectures/scipy.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,11 @@ SciPy 中有用的部分是其子包中的功能

### 随机变量与分布

回想一下,`numpy.random` 提供了生成随机变量的函数
回想一下,`numpy.random` 提供了生成随机变量的工具

```{code-cell} python3
np.random.beta(5, 5, size=3)
rng = np.random.default_rng()
rng.beta(5, 5, size=3)
```

当 `a, b = 5, 5` 时,这从具有以下密度函数的分布中生成一个样本
Expand Down Expand Up @@ -212,13 +213,13 @@ plt.show()
```{code-cell} python3
from scipy.stats import linregress

Comment on lines 213 to 215
x = np.random.randn(200)
y = 2 * x + 0.1 * np.random.randn(200)
x = rng.standard_normal(200)
y = 2 * x + 0.1 * rng.standard_normal(200)
gradient, intercept, r_value, p_value, std_err = linregress(x, y)
gradient, intercept
```

要查看完整列表,请参阅[文档](https://docs.scipy.org/doc/scipy/reference/stats.html#statistical-functions-scipy-stats)。
要查看完整列表,请参阅 [文档](https://docs.scipy.org/doc/scipy/reference/stats.html#statistical-functions-scipy-stats)。

## 根与不动点

Expand Down Expand Up @@ -591,8 +592,9 @@ $$ \mathbb E \max\{ S_n - K, 0 \}
以下是一种解答:

```{code-cell} ipython3
rng = np.random.default_rng()
M = 10_000_000
S = np.exp(μ + σ * np.random.randn(M))
S = np.exp(μ + σ * rng.standard_normal(M))
return_draws = np.maximum(S - K, 0)
P = β**n * np.mean(return_draws)
print(f"The Monte Carlo option price is {P:3f}")
Expand All @@ -607,9 +609,9 @@ print(f"The Monte Carlo option price is {P:3f}")
```{exercise}
:label: sp_ex1

在{ref}`本讲座 <functions>`中,我们讨论了{ref}`递归函数调用 <recursive_functions>`的概念。
{ref}`本讲座 <functions>` 中,我们讨论了 {ref}`递归函数调用 <recursive_functions>` 的概念。

尝试编写上面{ref}`描述的 <bisect_func>`自制二分函数的递归实现。
尝试编写上面 {ref}`描述的 <bisect_func>` 自制二分函数的递归实现。

用函数 {eq}`root_f` 对其进行测试。
```
Expand Down Expand Up @@ -647,4 +649,4 @@ bisect(f, 0, 1)
```

```{solution-end}
```
```
Loading