-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
569 lines (403 loc) · 29.2 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 6.3.0">
<link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
<link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
<link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
<link rel="mask-icon" href="/images/logo.svg" color="#222">
<link rel="stylesheet" href="/css/main.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" integrity="sha256-CTSx/A06dm1B063156EVh15m6Y67pAjZZaQc89LLSrU=" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">
<script class="next-config" data-name="main" type="application/json">{"hostname":"black-pwq.github.io","root":"/","images":"/images","scheme":"Muse","darkmode":false,"version":"8.18.2","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":{"enable":false,"style":null},"fold":{"enable":false,"height":500},"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":false,"transition":{"menu_item":"fadeInDown","post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果:${query}","hits_time":"找到 ${hits} 个搜索结果(用时 ${time} 毫秒)","hits":"找到 ${hits} 个搜索结果"}}</script><script src="/js/config.js"></script>
<meta name="description" content="Black的个人博客">
<meta property="og:type" content="website">
<meta property="og:title" content="Black的博客">
<meta property="og:url" content="https://black-pwq.github.io/index.html">
<meta property="og:site_name" content="Black的博客">
<meta property="og:description" content="Black的个人博客">
<meta property="og:locale" content="zh_CN">
<meta property="article:author" content="Black Pan">
<meta name="twitter:card" content="summary">
<link rel="canonical" href="https://black-pwq.github.io/">
<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":true,"isPost":false,"lang":"zh-CN","comments":"","permalink":"","path":"index.html","title":""}</script>
<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>Black的博客</title>
<noscript>
<link rel="stylesheet" href="/css/noscript.css">
</noscript>
</head>
<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
<div class="headband"></div>
<main class="main">
<div class="column">
<header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="site-brand-container">
<div class="site-nav-toggle">
<div class="toggle" aria-label="切换导航栏" role="button">
</div>
</div>
<div class="site-meta">
<a href="/" class="brand" rel="start">
<i class="logo-line"></i>
<h1 class="site-title">Black的博客</h1>
<i class="logo-line"></i>
</a>
</div>
<div class="site-nav-right">
<div class="toggle popup-trigger" aria-label="搜索" role="button">
</div>
</div>
</div>
</header>
<aside class="sidebar">
<div class="sidebar-inner sidebar-overview-active">
<ul class="sidebar-nav">
<li class="sidebar-nav-toc">
文章目录
</li>
<li class="sidebar-nav-overview">
站点概览
</li>
</ul>
<div class="sidebar-panel-container">
<!--noindex-->
<div class="post-toc-wrap sidebar-panel">
</div>
<!--/noindex-->
<div class="site-overview-wrap sidebar-panel">
<div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
<p class="site-author-name" itemprop="name">Black Pan</p>
<div class="site-description" itemprop="description">Black的个人博客</div>
</div>
<div class="site-state-wrap animated">
<nav class="site-state">
<div class="site-state-item site-state-posts">
<a href="/archives/">
<span class="site-state-item-count">3</span>
<span class="site-state-item-name">日志</span>
</a>
</div>
</nav>
</div>
<div class="links-of-author animated">
<span class="links-of-author-item">
<a href="https://github.com/black-pwq" title="GitHub → https://github.com/black-pwq" rel="noopener me" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
</span>
<span class="links-of-author-item">
<a href="mailto:black_pwq@qq.com" title="E-Mail → mailto:black_pwq@qq.com" rel="noopener me" target="_blank"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
</span>
</div>
</div>
</div>
</div>
</aside>
</div>
<div class="main-inner index posts-expand">
<div class="post-block">
<article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
<link itemprop="mainEntityOfPage" href="https://black-pwq.github.io/2024/02/20/linux-common-command/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="Black Pan">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Black的博客">
<meta itemprop="description" content="Black的个人博客">
</span>
<span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
<meta itemprop="name" content="undefined | Black的博客">
<meta itemprop="description" content="">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2024/02/20/linux-common-command/" class="post-title-link" itemprop="url">Linux Common Commands</a>
</h2>
<div class="post-meta-container">
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2024-02-20 16:53:21" itemprop="dateCreated datePublished" datetime="2024-02-20T16:53:21+08:00">2024-02-20</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2024-02-21 23:16:35" itemprop="dateModified" datetime="2024-02-21T23:16:35+08:00">2024-02-21</time>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="see-the-log-from-systemd-service-journalctl">See the log from systemd service: <code>journalctl</code></h1>
<h2 id="common-usage">Common usage</h2>
<p><code>journalctl -u UnitName --since today</code></p>
<p>Use right arrow key to scroll right. Or press <code>-S</code> and Enter in <code>less</code> to toggle word wrap.</p>
<p>Also see <a target="_blank" rel="noopener" href="https://www.digitalocean.com/community/tutorials/how-to-use-journalctl-to-view-and-manipulate-systemd-logs">DigitalOcean's website</a> for more usages.</p>
<h2 id="show-colorful-output">Show colorful output:</h2>
<p>If the original daemon output is already colorized, but the colors are being lost when using journalctl, the <code>--output cat</code> option will restore them. See the manual for more details.</p>
<blockquote>
<p>-o, --output= Controls the formatting of the journal entries that are shown. Takes one of the following options:</p>
</blockquote>
<blockquote>
<p>cat generates a very terse output, only showing the actual message of each journal entry with no metadata, not even a timestamp.</p>
</blockquote>
<h2 id="continuously-print-new-logs">Continuously print new logs</h2>
<p><code>journalctl --follow --no-tail</code> is used when you want all previous lines (better than -n 100000 or arbitrary big line count)</p>
<h2 id="restrict-the-output-to-latest-run">Restrict the output to latest run:</h2>
<p><a target="_blank" rel="noopener" href="https://serverfault.com/questions/768901/is-there-a-way-to-make-journalctl-show-logs-from-the-last-time-foo-service-ran">TL;DR</a>: Use the one liner:</p>
<ul>
<li>System level: <figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">journalctl _SYSTEMD_INVOCATION_ID=`systemctl show -p InvocationID --value service_name.service`</span><br></pre></td></tr></table></figure></li>
<li>User level: <figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">journalctl _SYSTEMD_INVOCATION_ID=`systemctl show -p InvocationID --value service_name.service --user`</span><br></pre></td></tr></table></figure></li>
</ul>
<h1 id="pythonconda-in-systemd-service">Python(conda) in systemd service</h1>
<p>Create a systemd Service File: Create a .service file (e.g., my_server.service) in a location of your choice (usually <code>/etc/systemd/system/</code> for system-level services or <code>~/.config/systemd/user/</code> for user-level services). Open the file for editing.</p>
<p>Define the Service:</p>
<ol type="1">
<li>Add the following content to your .service file: <figure class="highlight toml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="section">[Unit]</span></span><br><span class="line"><span class="attr">Description</span>=My Python Server</span><br><span class="line"></span><br><span class="line"><span class="section">[Service]</span></span><br><span class="line"><span class="attr">Type</span>=simple</span><br><span class="line"><span class="attr">ExecStart</span>=/path/to/conda/envs/env_name/bin/python python_file.py</span><br><span class="line"><span class="attr">WorkingDirectory</span>=/path/to/working/directory</span><br><span class="line"></span><br><span class="line"><span class="section">[Install]</span></span><br><span class="line"><span class="attr">WantedBy</span>=default.target</span><br></pre></td></tr></table></figure></li>
<li>Replace <code>/path/to/conda/envs/env_name</code> with the actual path to your Conda environment. Adjust the WorkingDirectory to the directory where your startup.py resides.</li>
</ol>
<p>Enable and Start the Service:</p>
<ul>
<li><p>If you’re running this as a user-level service, use: <figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">systemctl --user <span class="built_in">enable</span> my_server.service</span><br><span class="line">systemctl --user start my_server.service</span><br></pre></td></tr></table></figure></p></li>
<li><p>For system-level services, use: <figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">sudo systemctl <span class="built_in">enable</span> my_server.service</span><br><span class="line">sudo systemctl start my_server.service</span><br></pre></td></tr></table></figure></p></li>
</ul>
<h2 id="activate-a-conda-env-in-systemd-service">Activate a conda env in systemd service</h2>
<p>https://github.com/mmaz/systemd-conda</p>
<h1 id="shell-script">Shell script</h1>
<p>Accessing Individual Arguments: To access specific arguments, use the following variables:</p>
<ul>
<li><code>$0</code>: The script name itself.</li>
<li><code>$1</code>, <code>$2</code>, <code>$3</code>, …: The first, second, third, and subsequent arguments.</li>
<li><code>$#</code>: The total number of arguments.</li>
<li><code>$@</code>: All arguments as a list.</li>
<li><code>$$</code>: The process ID of the script.</li>
<li><code>$?</code>: The exit code of the last executed command.</li>
</ul>
<p>Example Script: <figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#!/bin/sh</span></span><br><span class="line"><span class="built_in">echo</span> <span class="string">"Script Name: <span class="variable">$0</span>"</span></span><br><span class="line"><span class="built_in">echo</span> <span class="string">"First Parameter: <span class="variable">$1</span>"</span></span><br><span class="line"><span class="built_in">echo</span> <span class="string">"Second Parameter: <span class="variable">$2</span>"</span></span><br><span class="line"><span class="built_in">echo</span> <span class="string">"All Arguments: <span class="variable">$@</span>"</span></span><br><span class="line"><span class="built_in">echo</span> <span class="string">"Total Number of Parameters: <span class="variable">$#</span>"</span></span><br><span class="line"><span class="built_in">echo</span> <span class="string">"Process ID: $$"</span></span><br><span class="line"><span class="built_in">echo</span> <span class="string">"Exit Code: $?"</span></span><br></pre></td></tr></table></figure></p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
</div>
<div class="post-block">
<article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
<link itemprop="mainEntityOfPage" href="https://black-pwq.github.io/2024/02/08/windows-dirs-structure/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="Black Pan">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Black的博客">
<meta itemprop="description" content="Black的个人博客">
</span>
<span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
<meta itemprop="name" content="undefined | Black的博客">
<meta itemprop="description" content="">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2024/02/08/windows-dirs-structure/" class="post-title-link" itemprop="url">Windows Directory Structure</a>
</h2>
<div class="post-meta-container">
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2024-02-08 23:54:06" itemprop="dateCreated datePublished" datetime="2024-02-08T23:54:06+08:00">2024-02-08</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2024-02-09 14:51:59" itemprop="dateModified" datetime="2024-02-09T14:51:59+08:00">2024-02-09</time>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="appdata目录详解"><code>%AppData%</code>目录详解</h1>
<p><code>%UserProfile%\AppData</code><a target="_blank" rel="noopener" href="https://www.howtogeek.com/278562/what-is-the-programdata-folder-in-windows/">通常存放用户相关的数据</a>,其下包含3个文件夹</p>
<ol type="1">
<li><code>Roaming</code>,由环境变量<code>%AppData%</code>表示其路径。是许多软件存放(通常与用户相关的)数据的路径。如名中<code>Roaming</code>所暗示的一样,该文件夹内的内容可通过网络同步到不同电脑,前提是在同一域中登入同一账户。<a target="_blank" rel="noopener" href="https://web.archive.org/web/20120621131135/http://technet.microsoft.com:80/en-us/library/cc766489(v=ws.10).aspx">该特性在<code>Windows Vista</code>中被详细介绍。</a></li>
<li><code>Local</code>,由环境变量<code>%LocalAppData%</code>表示其路径。与<code>Roaming</code>文件夹相似,但不会进行同步。</li>
<li><code>LocalLow</code>,此文件夹通常较为少用,与<code>Local</code>文件夹相似,但<a target="_blank" rel="noopener" href="https://superuser.com/questions/21458/why-are-there-directories-called-local-locallow-and-roaming-under-users-user">具备更低的集成度</a>。</li>
</ol>
<h2 id="常见的软件安装位置">常见的软件安装位置</h2>
<p><code>%LocalAppData%\Programs</code>是用来存放单用户安装程序的目录。<code>%LocalAppData%\Programs</code>与<code>%LocalAppData%\ProgramData</code>两者不会出现在<code>%AppData%</code>中。</p>
<p>例如vs code的安装路径就在<code>%LocalAppData%\Programs</code>。Vs code官网对单用户安装与系统级别的安装也进行了<a target="_blank" rel="noopener" href="https://code.visualstudio.com/docs/setup/windows">说明</a>。</p>
<blockquote>
<p>By default, VS Code is installed under <br> <code>C:\Users\{Username}\AppData\Local\Programs\Microsoft VS Code</code>.</p>
</blockquote>
<p>事实上,许多软件会滥用<code>%AppData%</code>目录。例如百度云安装的目录就在<code>%AppData%</code>中,但一般而言,该目录应当存放软件使用过程中产生的数据,而不是软件本身。</p>
<p>目前,Windows 10下软件安装的位置仍然很多样,但比较常见的安装位置通常分布在<code>%ProgramFile%</code>, <code>%ProgramFiles%\WindowsApps</code>以及<code>%LocalAppData%\Programs</code>下。安装在前两者的应用通常是系统层级的,而后者多为用户独有应用,其中<code>WindowsApps</code>通常为微软商店下载的应用位置,<a target="_blank" rel="noopener" href="https://blog.csdn.net/WPwalter/article/details/79394709?spm=1001.2014.3001.5506">即便具备管理员权限也通常不能访问</a>。</p>
<h2 id="常见的软件数据存放位置">常见的软件数据存放位置</h2>
<p>如前所述,<code>%AppData%</code>与<code>%LocalAppData%</code>中通常存放用户相关的软件数据。在两者下,常见的文件夹有Microsoft与Google等。例如微软Edge浏览器的用户数据通常存放在<code>%LocalAppData%\Microsoft\Edge</code>中。此外,由微软发布的非应用级的软件也有可能存放在Microsoft文件夹下。例如,vs code中的<code>C/C++</code>拓展的缓存目录就存放于此。</p>
<h1 id="userprofile目录"><code>%UserProfile%</code>目录</h1>
<p>该目录通常被称作用户家目录,其路径通常为<code>C:\Users\<username></code>。该目录通常存放一些应用的配置文件相关信息,其大部分配置文件采用类Unix的命名方式,以<code>.</code>作为前缀,尽管Windows并未对该类文件夹或文件赋予默认隐藏属性。一些非常常见的文件夹或文件包括:</p>
<ul>
<li><code>.m2</code>用于存放Maven仓库</li>
<li><code>.p2</code>存放Eclipse插件(Bundle)</li>
<li><code>.ssh</code>存放<code>ssh</code>配置文件相关</li>
<li><code>.vscode</code></li>
<li><code>.android</code></li>
<li>...</li>
</ul>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
</div>
<div class="post-block">
<article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
<link itemprop="mainEntityOfPage" href="https://black-pwq.github.io/2023/10/10/probability_suggestion/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="Black Pan">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Black的博客">
<meta itemprop="description" content="Black的个人博客">
</span>
<span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
<meta itemprop="name" content="undefined | Black的博客">
<meta itemprop="description" content="">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2023/10/10/probability_suggestion/" class="post-title-link" itemprop="url">Independence and Suggestion</a>
</h2>
<div class="post-meta-container">
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2023-10-10 16:13:16" itemprop="dateCreated datePublished" datetime="2023-10-10T16:13:16+08:00">2023-10-10</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2023-10-16 10:33:20" itemprop="dateModified" datetime="2023-10-16T10:33:20+08:00">2023-10-16</time>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="independence">Independence</h1>
<p>Page 73, Problem 1.43.</p>
<p>The events <span class="math inline">\(A\)</span> and <span class="math inline">\(B^c\)</span> are independent if <span class="math inline">\(A\)</span> and <span class="math inline">\(B\)</span> are independent. <span class="math display">\[\begin{aligned}
P(B)P(A) + P(A\cap B^c) = P(A) = P(B)P(A) + P(B^c)P(A)
\end{aligned} \]</span> The first equality holds because <span class="math display">\[\begin{aligned} P(A\cap B) + P(A\cap B^c) = P(A) = P(B)P(A) + P(A\cap B^c) \end{aligned}\]</span></p>
<h2 id="transitivity-of-independence-on-sets-complement">Transitivity of Independence on set's complement</h2>
<p>The events <span class="math inline">\(A^c\)</span> and <span class="math inline">\(B^c\)</span> are independent if <span class="math inline">\(A\)</span> and <span class="math inline">\(B\)</span> are independent. Apply the previous result on <span class="math inline">\(A\)</span> and <span class="math inline">\(B\)</span>, then on <span class="math inline">\(B^c\)</span> and <span class="math inline">\(A\)</span>.</p>
<h1 id="suggestion">Suggestion</h1>
<p>Page 69, Problem 1.29.</p>
<p>Let <span class="math inline">\(A\)</span> and <span class="math inline">\(B\)</span> be events with <span class="math inline">\(P(A) > 0\)</span> and <span class="math inline">\(P(B) > 0\)</span>. We say that an event <span class="math inline">\(B\)</span> suggests an event <span class="math inline">\(A\)</span> if <span class="math inline">\(P(A|B) > P(A)\)</span>, and does not suggest event <span class="math inline">\(A\)</span> if <span class="math inline">\(P(A|B) < P(B)\)</span>.</p>
<h2 id="suggestion-is-mutual">Suggestion is mutual</h2>
<p><span class="math display">\[\begin{aligned}
P(A|B) > P(A) \iff P(B|A)> P(B)
\end{aligned} \]</span></p>
<p><span class="math display">\[\begin{aligned}
P(A|B) &> P(A)\\
P(A\cap B)&>P(A)P(B)
\end{aligned}\]</span> Notice the symmetry in the above equivalent formula.</p>
<h2 id="suggestion-is-complementary">Suggestion is complementary</h2>
<p><span class="math display">\[\begin{aligned}
P(A|B) > P(A) \iff P(A|B^c) < P(A)
\label{eq:complement}
\end{aligned}\]</span></p>
<p><span class="math display">\[\begin{aligned}
P(B)P(A) + P(B^c)P(A) = P(A)= P(B)P(A | B) + P(B^c)P(A | B^c)
\end{aligned}\]</span> If <span class="math inline">\(P(A|B) > P(A)\)</span>, to make the above equality holds, <span class="math inline">\(P(A)\)</span> must be less than <span class="math inline">\(P(A|B^c)\)</span>.</p>
<p>Notice <a href="#eq:complement" data-reference-type="ref" data-reference="eq:complement">[eq:complement]</a> could be rewritten as <span class="math display">\[\begin{aligned}
P(A|B) > P(A) > P(A|B^c),
\end{aligned}\]</span> if <span class="math inline">\(A,B\)</span> suggest each other. Thus, the following argument is always true <span class="math display">\[\begin{aligned}
P(A|B) > P(A|B^c) \iff P(A|B) > P(A)
\end{aligned}\]</span></p>
<p>Suggestion is not only complement on the condition, but also on the conditional event, i.e., <span class="math display">\[\begin{aligned}
P(A|B) > P(A) \iff P(A^c|B) < P(A^c)
\end{aligned}\]</span></p>
<p><span class="math display">\[\begin{aligned}
P(A|B) + P(A^c|B) = 1= P(A) + P(A^c)
\end{aligned}\]</span></p>
<p>Double complement suggestion have the same result as the original. In other words, <span class="math display">\[\begin{aligned}
P(A|B) > P(A) \iff P(A^c|B^c) > P(A^c)
\end{aligned}\]</span> This equivalence is trivial by the above arguments.</p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
</div>
</div>
</main>
<footer class="footer">
<div class="footer-inner">
<div class="copyright">
©
<span itemprop="copyrightYear">2024</span>
<span class="with-love">
<i class="fa-regular fa-heart"></i>
</span>
<span class="author" itemprop="copyrightHolder">Black Pan</span>
</div>
</div>
</footer>
<div class="toggle sidebar-toggle" role="button">
<span class="toggle-line"></span>
<span class="toggle-line"></span>
<span class="toggle-line"></span>
</div>
<div class="sidebar-dimmer"></div>
<div class="back-to-top" role="button" aria-label="返回顶部">
<i class="fa fa-arrow-up fa-lg"></i>
<span>0%</span>
</div>
<noscript>
<div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>
<script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/schemes/muse.js"></script><script src="/js/next-boot.js"></script>
<script class="next-config" data-name="enableMath" type="application/json">true</script><script class="next-config" data-name="mathjax" type="application/json">{"enable":true,"tags":"none","js":{"url":"https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-mml-chtml.js","integrity":"sha256-MASABpB4tYktI2Oitl4t+78w/lyA+D7b/s9GEP0JOGI="}}</script>
<script src="/js/third-party/math/mathjax.js"></script>
<script class="next-config" data-name="giscus" type="application/json">{"enable":true,"repo":"black-pwq/black-pwq.github.io","repo_id":"R_kgDOKZDrYA","category":"Announcements","category_id":"DIC_kwDOKZDrYM4CaAWS","mapping":"pathname","reactions_enabled":1,"emit_metadata":0,"theme":"preferred_color_scheme","lang":"zh-CN","crossorigin":"anonymous","input_position":"bottom","loading":"lazy"}</script>
<script>
document.addEventListener('page:loaded', () => {
if (!CONFIG.page.comments) return;
NexT.utils.loadComments('.giscus-container')
.then(() => NexT.utils.getScript('https://giscus.app/client.js', {
attributes: {
async : true,
crossOrigin : 'anonymous',
'data-repo' : CONFIG.giscus.repo,
'data-repo-id' : CONFIG.giscus.repo_id,
'data-category' : CONFIG.giscus.category,
'data-category-id' : CONFIG.giscus.category_id,
'data-mapping' : CONFIG.giscus.mapping,
'data-reactions-enabled': CONFIG.giscus.reactions_enabled,
'data-emit-metadata' : CONFIG.giscus.emit_metadata,
'data-theme' : CONFIG.giscus.theme,
'data-lang' : CONFIG.giscus.lang,
'data-input-position' : CONFIG.giscus.input_position,
'data-loading' : CONFIG.giscus.loading
},
parentNode: document.querySelector('.giscus-container')
}));
});
</script>
</body>
</html>