<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tang&#039;s Blog</title>
	<atom:link href="http://localhost/feed/" rel="self" type="application/rss+xml" />
	<link>/</link>
	<description></description>
	<lastBuildDate>Sun, 02 Oct 2022 10:19:12 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.0.2</generator>

<image>
	<url>/wp-content/uploads/2022/05/cropped-icon-32x32.png</url>
	<title>Tang&#039;s Blog</title>
	<link>/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>我人间清醒，也认真疯狂</title>
		<link>/2022/10/02/man_of_la_mancha/</link>
					<comments>/2022/10/02/man_of_la_mancha/#respond</comments>
		
		<dc:creator><![CDATA[Tang]]></dc:creator>
		<pubDate>Sun, 02 Oct 2022 10:19:10 +0000</pubDate>
				<category><![CDATA[Writing]]></category>
		<guid isPermaLink="false">/?p=638</guid>

					<description><![CDATA[游侠骑士要到世界最偏远的地方去，闯入最困难的迷津，争取做到常人难以做到的事情。 在草木稀少的地方，顶着酷夏的炎 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<div class="wp-block-cover alignfull rocket-lazyload lazyloaded" style="background-position: 50% 50%; background-image: url(&quot;/wp-content/uploads/2022/10/7541664705736_.pic_hd-1024x726.jpg&quot;);" data-ll-status="loaded"><div class="wp-block-cover__inner-container"><p class="has-text-align-center has-large-font-size"></p></div></div>



<p>游侠骑士要到世界最偏远的地方去，闯入最困难的迷津，争取做到常人难以做到的事情。 在草木稀少的地方，顶着酷夏的炎炎烈日，在冰天雪地的严冬冒着凛冽的寒冷，狮子吓不 他们，在魑魅魍魉面前他们也无所畏惧，而是寻找它们，向它们进攻，战胜它们，这才是游侠骑士真正重要的职责。</p>



<p><strong>如果这个世界本身已经足够荒唐，那到底什么才能算是疯狂？</strong>也许太过实际就是疯狂。放弃梦想也许是疯狂。寻找着珍宝，可周围却只有垃圾。太过清醒也许正是疯狂。但是最疯狂的，莫过于接受现实，而不去想这世界到底应该是什么样子！</p>



<p>而人间，定会不同往昔，纵然我，终将疲倦无力，仍要用伤痕累累的双手，去摘，遥不可及的星！</p>
]]></content:encoded>
					
					<wfw:commentRss>/2022/10/02/man_of_la_mancha/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>《蛤蟆先生去看心理医生》</title>
		<link>/2022/08/27/counselling-for-toads-a-psychological-adventure/</link>
					<comments>/2022/08/27/counselling-for-toads-a-psychological-adventure/#respond</comments>
		
		<dc:creator><![CDATA[Tang]]></dc:creator>
		<pubDate>Sat, 27 Aug 2022 12:33:50 +0000</pubDate>
				<category><![CDATA[Reading]]></category>
		<guid isPermaLink="false">/?p=632</guid>

					<description><![CDATA[《蛤蟆先生去看心理医生》，听书名像是童书，其实是一本非常专业，写给成年人的心灵疗愈书。在阅读过程中，你可以跟着蛤蟆先生一起，探寻情绪的根源、体验咨询的细节，完成一场自我的疗愈。]]></description>
										<content:encoded><![CDATA[
<p>《蛤蟆先生去看心理医生》，听书名像是童书，其实是一本非常专业，写给成年人的心灵疗愈书。在阅读过程中，你可以跟着蛤蟆先生一起，探寻情绪的根源、体验咨询的细节，完成一场自我的疗愈。</p>



<p>为方便记忆，本书的重点我以“1+2+3+4”的数字进行提炼，即：</p>



<ul><li><strong>1个前提</strong>。改变的唯一前提是认识你自己，在这个世界上能帮你的人，只有你自己。</li><li><strong>2个思维</strong>。人人在理性与感性之间徘徊。真正厉害的人，是理性与感性并存。</li><li><strong>3个状态</strong>。每个人都有儿童、父母以及成年人的状态，三位一体，成年人之所以痛苦，恰恰是因为不在成人状态。</li><li><strong>4个坐标</strong>。人生有四个坐标，你选择的坐标决定了你成为什么样的人，“你好我好”是我们奋斗的终极目标。</li></ul>



<h2>Part 1——1个前提</h2>



<p>改变的唯一前提是认识你自己，在这个世界上能帮你的人，只有你自己。</p>



<p>蛤蟆先生第一次拜访苍鹭的时候，苍鹭开门见山道：“你今天怎么样？”，蛤蟆先生脱口而出：“挺好的，谢谢你。”尽管他并不好，但习惯告诉他我应该这么回答，为什么会有这样下意识的反应呢？</p>



<p>因为，我们从小就被大人灌输了这样的观点：表现悲伤、愤怒这样的负面情绪是无能懦弱的表现，是会被嫌弃和厌烦的。所以，我们学会了欺骗自己，隐瞒自己的真实情绪，好像只有这么做，大人才会开心，我们就不会受伤。所以，当苍鹭让蛤蟆先生描述自己真实感受的时候，他一时半会儿也弄不清自己有什么情绪。</p>



<p>当蛤蟆说“我就是一个不会生气的人”的时候，苍鹭识破了他为自己编织的假象，蛤蟆意识到，他不是不会生气，而是选择了另一种方式生气。当蛤蟆说“我很好”的时候，苍鹭让他看清了自己的悲伤与绝望，他不断追问蛤蟆的真实感觉，因为真实才是了解内心世界的入口。当蛤蟆责怪身边的人如何误解、让他伤心的时候，苍鹭点破了他最大的谎言：没有人能让你不快乐，是你自己选择了让自己不快乐。</p>



<p>改善情绪的第一步正是认识你自己，分辨你内心的真实情绪。</p>



<p>为了让蛤蟆先生的情绪量化可见，苍鹭使出了“情感温度计”的方法，温度计被划分为10个刻度，最低为1，代表非常糟糕，可能想自杀，5分代表还能承受，最高分是10分，表示非常愉悦。</p>



<p>蛤蟆先生第一次给自己打了1-2分，随着咨询次数的增加，他给自己的打分越来越高。这种打分机制不是考试，我们不用刻意在乎分数本身，只需将内心的感受真实呈现，有助于我们进一步了解自己、作出调整。</p>



<p>蛤蟆先生完成第一次咨询，离开的时候问了苍鹭一句：“你认为我会好起来吗？”苍鹭回答：“我相信每个人都有能力变得更好，我也会对你倾注我全身心的关注。但一切归根结底，都取决于你，能帮你的人是你自己，也只有你自己。”</p>



<h2>Part 2——2个思维</h2>



<p>人人在理性与感性之间徘徊。真正厉害的人，是理性与感性并存。</p>



<p>在接下来的咨询过程中，蛤蟆先生逐步意识到，人人的大脑里，都存在着两种思维模式，理性思维和感性思维。蛤蟆先生在一开始选择抑郁，其实就是选择了感性思维，像个婴儿一样，只做出本能反应。而从他接受疗愈，愿意剖析自己的时候，就是回归了理性思维。</p>



<p>什么是理性，什么又是感性呢？简单来说，理性就是一个人对某一件事能够做出理智的分析和判断，头脑不发热，决策不冲动。而感性则是一个人对待某一件事完全凭借心情，容易感情用事，不计后果。不同的事情有不同的处理方式，不能说一个人理性好，也不能说一个人感性不好，这要看事情的本质面貌。</p>



<p>于丹曾说：“我们需要一种清明的理性，这个理性是在这种嘈杂的世界中拯救生命的一种力量。同时，我们也需要一种欢欣的感性。这种感性之心可以使我们触目生春，所及之处充满了快乐。”</p>



<p>所以说，有时候感性和理性是需要并存的。一个人少了感性，会显得没人情味；少了理性，又会显得太死板。所以，正确的做法是，寻求感性和理性之间的平衡。当你感受到快乐时，你要让感性尽情飞驰；当你感受到痛苦时，要让理性来干预感性从而减轻不适。</p>



<h2>Part 3——3个状态</h2>



<p>每个人都有儿童、父母以及成年人的状态，三位一体，成年人之所以痛苦，恰恰是因为不在成人状态。</p>



<p>苍鹭在蛤蟆先生咨询的过程中，将我们的人生分为：儿童、成人、父母三个状态。</p>



<p>1、儿童自我状态。当一个人处于儿童自我状态时，他会下意识用童年时的习惯作出反应，表现出像孩子一样的感受和行为。在这种状态下，他会本能地顺从和依赖他人，再现过去的情形，体验过去压抑的痛苦情绪，学不到任何新的东西。</p>



<p>2、父母自我状态。处在父母自我状态的人，不是在挑剔别人就是在挑剔自己。处在这种状态下的人，会用言行重复父母那里学到的是非观和价值观，想方设法让别人接受自己的这套想法。甚至会将审判的矛头指向自己，进行毫不留情的自我批判。</p>



<p>3、成人自我状态。在成人自我状态的时候，我们能摆脱情绪化的控制，合理地计划、考虑、决定、行动，用知识和技能解决当下的事情。成人自我状态是唯一能学到自我新知识的状态，因为在儿童自我状态里，只是在体验过去的情绪，在父母自我状态里，不是挑剔就是在教育别人，所以这两种状态都不会学到东西。</p>



<p>那么，我们该如何适时调动成人自我状态呢？</p>



<p>其实，这又回归到了第一个话题——认识你自己。你需要不断思考你是谁、你从哪里来、你要到哪里去、你该如何才能到那里去。</p>



<p>蛤蟆先生在认真分析后意识到，成年的他其实一直处在儿童自我状态。</p>



<p>童年的蛤蟆，出身显赫，却一直不快乐。父亲时常对他批评责备，母亲则是对父亲的权威百依百顺，很少去拥抱、安慰自己。为了讨好父母的爱，童年的蛤蟆不得不做出，顺从、取悦、道歉、依赖等行为，并逐步形成了依赖及取悦型人格。而成长的本质就是逐渐打破依赖关系，成为独立人，顺从导致蛤蟆把依赖当成生活本身，童年依赖父母，成年则依赖外界的肯定，一旦收到否定反应，他要么取悦别人，要么自我批判，痛苦不堪，所以一直长不大。</p>



<p>“每个孩子生下来都是一张白纸，父母就是作画的人，白纸变成怎样，关键在父母。”，成年人的行为习惯都是从童年学来的，也会潜移默化的影响人一生。</p>



<h2>Part 4——4个坐标</h2>



<p>人生有四个坐标，你选择的坐标决定了你成为什么样的人，“你好我好”是我们奋斗的终极目标。</p>



<p>苍鹭曾问过蛤蟆两个问题：第一个问题是：你是怎么看自己的？你好吗？第二个问题是：你是怎么看别人的？他好吗？</p>



<p>根据这两个问题的回答，产生了以下四种人生坐标：</p>



<figure class="wp-block-image size-full"><img width="868" height="868" src="/wp-content/uploads/2022/08/7051661603094_.pic_.jpg" alt="" class="wp-image-634" srcset="/wp-content/uploads/2022/08/7051661603094_.pic_.jpg 868w, /wp-content/uploads/2022/08/7051661603094_.pic_-300x300.jpg 300w, /wp-content/uploads/2022/08/7051661603094_.pic_-150x150.jpg 150w, /wp-content/uploads/2022/08/7051661603094_.pic_-768x768.jpg 768w, /wp-content/uploads/2022/08/7051661603094_.pic_-720x720.jpg 720w, /wp-content/uploads/2022/08/7051661603094_.pic_-580x580.jpg 580w, /wp-content/uploads/2022/08/7051661603094_.pic_-320x320.jpg 320w" sizes="(max-width: 868px) 100vw, 868px" /><figcaption>人生坐标与心理游戏</figcaption></figure>



<p>1、你好，我不好。处在这个坐标的人认为自己是生活的受害者，无法掌控人生，从而产生焦虑、抑郁、自责等情绪。</p>



<p>2、我好，你不好。处于这个坐标的人常常会占据权力和权威的制高点，时常攻击、指责别人，产生愤怒、挑剔、指责等情绪。</p>



<p>3、我不好，你也不好。处于这个坐标的人更确切来说是“犯罪者”，既自卑又自大，既自我贬低也攻击他人，情绪反复无常，很容易产生报复社会的行为。</p>



<p>4、你好，我也好。这不仅是一种状态，更是一种选择和承诺。你相信自己是好的，更相信别人是好的，通过行为和态度，持续对自己和别人展现美好。</p>



<p>蛤蟆先生在最后一次进行心理咨询时，放弃了以前迷恋的汽车，选择了骑自行车到苍鹭那里，沿路他欣赏风景，聆听大自然的心跳，觉得身心愉悦至极。到达苍鹭那里后，苍鹭一如既往的问他，感觉怎么样。蛤蟆这次毫不犹豫说“我感觉好极了。”他已经在着手规划未来，不像以前只是想一想，而是真正有细节、有日程、有行动。蛤蟆先生给自己的“情感温度计”打了9分，并把自己的人生标记在 “你好，我也好”的坐标里。因为此刻，他内心有足够的安全感，相信自己的成长和能力，同时也欣赏他人的优点，能够与他人很好地合作，相互促进。</p>



<p>在和蛤蟆的面谈中，苍鹭也收获了成长，他不再像以前那么教条、严苛。他对蛤蟆先生说，这个状态是人生的更高级状态——共情。</p>



<p>“共情能让你在自我成长和完善的路上走得更远，因为它将带你从独立的个体走向共生的关系。独立性隐含了做自己的自豪感，还包括独特的才能、与众不同的部分。独立的人时刻守护新发现的自主权。但共生性则体现出成熟和自我接纳，可以让你在社交和工作上与别人有效联结，协同合作。”</p>



<p>这句话，我们也可以用特蕾莎修女的一句经典名言来理解:</p>



<p>“真正意义上的爱，既是爱自己，也是爱别人。爱生命里一切需要爱的事物，无需理由。哪怕生命微小到只是一根细小的灯芯，燃烧了，就能照亮自己，也能照亮他人。甚至，你还可以尝试去照亮一个世界。”</p>
]]></content:encoded>
					
					<wfw:commentRss>/2022/08/27/counselling-for-toads-a-psychological-adventure/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>正态分布</title>
		<link>/2022/07/04/normal-distribution/</link>
					<comments>/2022/07/04/normal-distribution/#respond</comments>
		
		<dc:creator><![CDATA[Tang]]></dc:creator>
		<pubDate>Mon, 04 Jul 2022 11:12:26 +0000</pubDate>
				<category><![CDATA[Math]]></category>
		<guid isPermaLink="false">/?p=617</guid>

					<description><![CDATA[1、正态分布 如果随机变量$X$的概率密度为$$f(x)=\frac{1}{\sqrt{2\pi\sigma} [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h2>1、正态分布</h2>



<p>如果随机变量$X$的概率密度为<br>$$f(x)=\frac{1}{\sqrt{2\pi\sigma}}e^{-\frac{1}{2\sigma ^2}(x-\mu )^2},-\infty&lt;x&lt;+\infty\tag 1$$</p>



<p>其中，$\sigma&gt;0,\sigma,\mu$为常数，则称$X$服从参数为$\sigma,\mu$的正态分布，记作$X\sim N(\mu,\sigma^2)$。</p>



<p>特别地，当$\mu=0,\sigma^2=1$时，称$X$服从标准正态分布，即$X \sim N(0,1)$，其概率密度函数和分布函数分别用$\phi(x),\Phi(x)$表示。<br>$$\phi(x)=\frac{1}{\sqrt{2\pi}}e^{-\frac{x^2}{2}},-\infty&lt;x&lt;+\infty\tag 2$$<br>$$\Phi(x)=\int_{-\infty}^{x}\phi(x)dx=\int_{-\infty}^{x}\frac{1}{\sqrt{2\pi}}e^{-\frac{t^2}{2}}dt\tag 3$$</p>



<p>若$X\sim N(\mu,\sigma^2)$，则</p>



<ol><li>$Y=aX+b\sim N(a\mu+b,a^2\sigma^2)$，其中$a\neq0,b$为常数；</li><li>$Y=\frac{X-\mu}{\sigma}\sim N(0,1)$（标准化）</li></ol>



<p>那么<br>(1) $F(x)=P{X\leq x}=P{\frac{X-\mu}{\sigma}\leq\frac{x-\mu}{\sigma}}=\Phi(\frac{x-\mu}{\sigma})$<br>(2) $f(x)=F'(x)=\frac{1}{\sigma}\phi(\frac{x-\mu}{\sigma})$<br>(3) 对任意区间$[x_1,x_2],P{X_1&lt;x\leq x_2}=P{\frac{x_1-\mu}{\sigma}&lt;X\leq \frac{x_2-\mu}{\sigma}}=\Phi(\frac{x_1-\mu}{\sigma})-\Phi(\frac{x_2-\mu}{\sigma})$</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2>2、二维正态分布</h2>



<p>设二维随机变量$(X,Y)$的概率密度为<br></p>



<p>$$f(x,y)=\frac{1}{2\pi\sigma_1\sigma_2\sqrt{1-\rho^2}}exp{-\frac{1}{2(1-\rho^2)}[\frac{(x-\mu_1)^2}{\sigma_1^2}-\frac{2\rho(x-\mu_1)(y-\mu_2)}{\sigma_1\sigma_2}+\frac{(y-\mu_2)^2}{\sigma_2^2}]},$$<br>$$-\infty&lt;x&lt;+\infty,-\infty&lt;y&lt;+\infty\tag 4$$<br>其中，$\mu_1,\mu_2,\sigma_1,\sigma_2,\rho$都是常数，且$\sigma_1&gt;0,\sigma_2&gt;0,-1&lt;\rho&lt;1$，则称$(X,Y)$服从参数为$\mu_1,\mu_2,\sigma_1,\sigma_2,\rho$的二维正态分布，记作$(X,Y)\sim N(\mu_1,\mu_2,\sigma_1,\sigma_2,\rho)$，它是最常见的二维连续型分布，它的图形就好像是一个草帽。</p>



<p>设$(X,Y)服从参数为\mu_1,\mu_2,\sigma_1,\sigma_2,\rho$的二维正态分布，<br>$$f_X(x)=\frac{1}{\sqrt{2\pi\sigma_1}}e^{-\frac{(x-\mu_1)^2}{2\sigma_1^2}},-\infty&lt;x&lt;+\infty\tag 5$$</p>



<p>$$f_Y(y)=\frac{1}{\sqrt{2\pi\sigma_2}}e^{-\frac{(y-\mu_2)^2}{2\sigma_2^2}},-\infty&lt;y&lt;+\infty\tag 6$$</p>



<p>二维正态分布的两个边缘分布是一维正态分布，并且都不依赖于参数$\rho$，即对于给定的$\mu_1,\mu_2,\sigma_1,\sigma_2$，不同的$\rho$对应不同的二维正态分布，但他们的边缘分布却是一样的。这一事实表明，但有关于$X$和$Y$的边缘分布，一般来说是不能确定随机变量$X$和$Y$的联合分布的。两个边缘分布都是正态分布的二维随机变量，他们的联合分布还可以不是二维正态分布。</p>



<p>设$(X,Y)服从参数为\mu_1,\mu_2,\sigma_1,\sigma_2,\rho$的二维正态分布，<br>$$f_{X|Y}(x|y)=\frac{f(x,y)}{f_Y(y)}=\frac{1}{\sqrt{2\pi}\sqrt{\sigma_1^2(1-\rho^2)}}\cdot exp{-\frac{1}{2\sigma_1^2(1-\rho^2)}[x-(\mu_1+\rho\frac{\sigma_1}{\sigma_2}(y-\mu_2))]^2},$$<br>$$-\infty&lt;x&lt;+\infty\tag 7$$</p>



<p>$$f_{Y|X}(y|x)=\frac{f(x,y)}{f_X(x)}=\frac{1}{\sqrt{2\pi}\sqrt{\sigma_2^2(1-\rho^2)}}\cdot exp{-\frac{1}{2\sigma_2^2(1-\rho^2)}[y-(\mu_2+\rho\frac{\sigma_2}{\sigma_1}(x-\mu_1))]^2},$$<br>$$-\infty&lt;y&lt;+\infty\tag 8$$</p>



<p>以上结果表明，在给定$X=x$下，$Y$的条件概率密度服从正态分布$N(\mu_2+\rho\frac{\sigma_2}{\sigma_1}(x-\mu_1),\sigma_2^2(1-\rho^2))$；在给定$Y=y$下，$X$的条件概率正态分布$N(\mu_1+\rho\frac{\sigma_1}{\sigma_2}(y-\mu_2),\sigma_1^2(1-\rho^2))$。<br>注：联合分布唯一确定边缘分布和条件分布，反之，边缘分布和条件分布都不能唯一确定联合分布，但一个条件分布和对应的边缘分布一起，能唯一确定联合分布，这是因为$f(x,y)=f_x(x)f_{Y|X}(y|x)$。</p>



<p>设$(X,Y)$是二维正态随机变量，它的概率密度为<br>$$f(x,y)=\frac{1}{2\pi\sigma_1\sigma_2\sqrt{1-\rho^2}}exp{-\frac{1}{2(1-\rho^2)}[\frac{(x-\mu_1)^2}{\sigma_1^2}-\frac{2\rho(x-\mu_1)(y-\mu_2)}{\sigma_1\sigma_2}+\frac{(y-\mu_2)^2}{\sigma_2^2}]}$$<br>证明$X$与$Y$相互独立的充要条件为$\rho=0$。</p>



<p><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-typology-acc-color"><strong>证</strong></mark><br>(1) 随机变量$X$边缘密度函数为<br>$$f_X(x)=\frac{1}{\sqrt{2\pi\sigma_1}}e^{\frac{(x-\mu_1)^2}{2\sigma_1^2}},-\infty&lt;x&lt;+\infty$$</p>



<p>又随机变量$Y$边缘密度函数为<br>$$f_Y(y)=\frac{1}{\sqrt{2\pi\sigma_2}}e^{\frac{(y-\mu_2)^2}{2\sigma_2^2}},-\infty&lt;y&lt;+\infty$$</p>



<p>所以当$rho=0$时，$(X,Y)$的联合密度函数为<br>$$f(x,y)=\frac{1}{2\pi\sigma_1\sigma_2}exp{-\frac{1}{2}[\frac{(x-\mu_1)^2}{\sigma_1^2}+\frac{(y-\mu_2)^2}{\sigma_2^2}]}=f_X(x)\cdot f_Y(y)$$<br>这表明随机变量$X$和$Y$相互独立。</p>



<p>(2) 反之,如果随机变量$X$和$Y$相互独立，则对于任意的实数$x,y$有<br>$$f(x,y)=f_X(x)\cdot f_Y(y)$$</p>



<p>特别地，有<br>$$f(\mu_1,\mu_2)=f_X(\mu_1)\cdot f_Y(\mu_2)$$</p>



<p>即<br>$$\frac{1}{2\pi\sigma_1\sigma_2\sqrt{1-\rho^2}}=\frac{1}{\sqrt{2\pi}\sigma_1}\cdot \frac{1}{\sqrt{2\pi}\sigma_2}$$<br>由此得$\rho=0$</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2>3、正态分布的重要性质</h2>



<p>$$EX=\mu \tag 9$$<br>$$DX=\sigma^2 \tag {10}$$</p>



<p>若$X_i\sim N(\mu_i,\sigma_i^2)(i=1,2,\cdots,n)$且它们相互独立，则他们的线性组合<br>$$a_1X_1+a_2+X_2+\cdots+a_nX_n$$<br>（其中$a_1,a_2,\cdots,a_n$是不全为0的常数）仍服从正态分布，即<br>$$a_1X_1+a_2+X_2+\cdots+a_nX_n\sim N(\sum_{i=1}^{n}a_i\mu_i,\sum_{i=1}^na_i^2\sigma_i^2)\tag {11}$$</p>
]]></content:encoded>
					
					<wfw:commentRss>/2022/07/04/normal-distribution/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>LaTeX 中表格的宽度控制</title>
		<link>/2022/06/02/latex_table/</link>
					<comments>/2022/06/02/latex_table/#respond</comments>
		
		<dc:creator><![CDATA[Tang]]></dc:creator>
		<pubDate>Thu, 02 Jun 2022 02:53:52 +0000</pubDate>
				<category><![CDATA[Technology]]></category>
		<guid isPermaLink="false">/?p=588</guid>

					<description><![CDATA[在利用 LaTeX 进行排版时，最令人头疼的一个问题莫过于表格的制作。一方面是表格的格式复杂多变，二是表格内容 [&#8230;]]]></description>
										<content:encoded><![CDATA[
在利用 <span class="texhtml" style="font-family: 'CMU Serif', cmr10, LMRoman10-Regular, 'Latin Modern Math', 'Nimbus Roman No9 L', 'Times New Roman', Times, serif;">L<span style="text-transform: uppercase; font-size: 0.75em; vertical-align: 0.25em; margin-left: -0.36em; margin-right: -0.15em; line-height: 1ex;">a</span>T<span style="text-transform: uppercase; vertical-align: -0.25em; margin-left: -0.1667em; margin-right: -0.125em; line-height: 1ex;">e</span>X</span> 进行排版时，最令人头疼的一个问题莫过于表格的制作。一方面是表格的格式复杂多变，二是表格内容分散且内容繁多，都造成排版的难度增加。好在这个问题可以通过 <a href="https://www.tablesgenerator.com/">Tables Generator</a> 这一在线工具来得到缓解。但表格的格式还有一点令人感到棘手，就是<b>宽度</b>。不是内容太少导致表格细而长，就是类目太多导致表格超出了页面。本文旨在将最近排版中学到的三种方法进行总结，并对其优劣及适用场景进行分析。<div style="margin-bottom:2.5em"></div>



<h2>1. 使用命令 \setlength{\tabcolsep} </h2>



<pre class="wp-block-code has-typology-txt-color has-text-color has-background language-python line-numbers" style="background-color:#f0f0f0" tabindex="0"><code lang="tex" class="language-tex">\begin{table*}[!htbp]
\centering
\caption{Quantitative depth SR results (in MAD) on Middlebury 2005 dataset. The best performance is displayed in bold, and the second best performance is marked in underline.}
%\renewcommand{\arraystretch}{0.85}
\setlength{\tabcolsep}{1.mm}{
\begin{tabular}{c|ccc|ccc|ccc|ccc|ccc|ccc}
\hline
\multirow{2}{*}{} & \multicolumn{3}{c|}{Art} & \multicolumn{3}{c|}{Books} & \multicolumn{3}{c|}{Dolls} & \multicolumn{3}{c|}{Laundry} & \multicolumn{3}{c|}{Mobius} & \multicolumn{3}{c}{Reindeer} \\
\cline{2-19}
 &$\times 4$  &$\times 8$  &  $\times 16$& $\times 4$ & $\times 8$ & $\times 16$ & $\times 4$ & $\times 8$ & $\times 16$ & $\times 4$ & $\times 8$ & $\times 16$ & $\times 4$ & $\times 8$ & $\times 16$ & $\times 4$ & $\times 8$ & $\times 16$ \\
 \hline
 CLMF & 0.76 & 1.44 & 2.87 & 0.28 & 0.51 & 1.02 & 0.34 & 0.60 & 1.01 & 0.50 & 0.80 & 1.67 & 0.29 & 0.51 & 0.97 & 0.51 & 0.84 & 1.55 \\
 JGF & 0.47 & 0.78 & 1.54 & 0.24 & 0.43 & 0.81 & 0.33 & 0.59 & 1.06 & 0.36 & 0.64 & 1.20 & 0.25 & 0.46 & 0.80 & 0.38 & 0.64 & 1.09\\
 TGV & 0.65 & 1.17 & 2.30 & 0.27 & 0.42 & 0.82 & 0.33 & 0.70 & 2.20 & 0.55 & 1.22 & 3.37 & 0.29 & 0.49 & 0.90 & 0.49 & 1.03 & 3.05\\
 CDLLC & 0.53 & 0.76 & 1.41 & 0.19 & 0.46 & 0.75 & 0.31 & 0.53 & 0.79 & 0.30 & 0.48 & 0.96 & 0.27 & 0.46 & 0.79 & 0.43 & 0.55 & 0.98\\
 PB & 0.79 & 0.93 & 1.98 & 0.16 & 0.43 & 0.79 & 0.53 & 0.83 & 0.99 & 1.13 & 1.89 & 2.87 & 0.17 & 0.47 & 0.82 & 0.56 & 0.97 & 1.89\\
 EG & 0.48 & 0.71 & \underline{1.35} & 0.15 & 0.36 & 0.70 & 0.27 & 0.49 & 0.74 & 0.28 & 0.45 & 0.92 & 0.23 & 0.42 & 0.75 & 0.36 & 0.51 & 0.95\\\hline
 SRCNN & 0.63 & 1.21 & 2.34 & 0.25 & 0.52 & 0.97 & 0.29 & 0.58 & 1.03 & 0.40 & 0.87 & 1.74 & 0.25 & 0.43 & 0.87 & 0.35 & 0.75 & 1.47 \\
 ATGVNet & 0.65 & 0.81 & 1.42 & 0.43 & 0.51 & 0.79 &0.41  & 0.52 & \textbf{0.56} & 0.37 & 0.89 & 0.94 & 0.38 &  0.45& 0.80 & 0.41 & 0.58 &1.01 \\
 MSG & 0.46 & 0.76 & 1.53 & 0.15 & 0.41 & 0.76 & 0.25 & 0.51 & 0.87 & 0.30 & 0.46 & 1.12 & 0.21 & 0.43 & 0.76 & 0.31 & 0.52 & 0.99\\
 DGDIE & 0.48 & 1.20 &2.44  & 0.30 & 0.58 & 1.02 & 0.34 & 0.63 & 0.93 & 0.35 & 0.86 & 1.56 & 0.28 & 0.58 & 0.98 & 0.35 & 0.73 &1.29 \\
 DEIN & 0.40 & 0.64 & \textbf{1.34} & 0.22 & 0.37 & 0.78 & 0.22 & 0.38 & 0.73 & 0.23 & \underline{0.36} & 0.81 & 0.20 & 0.35 & 0.73 & 0.26 & 0.40 & 0.80\\
 CCFN & 0.43 & 0.72 & 1.50 & 0.17 & 0.36 & 0.69 & 0.25 & 0.46 & 0.75 & 0.24 & 0.41 & \textbf{0.71} & 0.23 & 0.39 & 0.73 & 0.29 & 0.46 & 0.95\\
 GSRPT & 0.48 & 0.74 & 1.48 & 0.21 & 0.38 & 0.76 & 0.28 & 0.48 & 0.79 & 0.33 & 0.56 & 1.24 & 0.24 & 0.49 &  0.80& 0.31 & 0.61 &1.07 \\
CTKT & \textbf{0.25} & \textbf{0.53} & 1.44 & \textbf{0.11} & \underline{0.26} & \underline{0.67} & \textbf{0.16} & \underline{0.36} & 0.65 & \textbf{0.16} & \underline{0.36} & \underline{0.76} & \textbf{0.13} & \underline{0.27} & \underline{0.69} & \textbf{0.17} & \underline{0.35} & \underline{0.77}\\
BridgeNet (Ours)& \underline{0.30} & \underline{0.58} & 1.49 & \underline{0.14} & \textbf{0.24} & \textbf{0.51} &\underline{0.19}  & \textbf{0.34} & \underline{0.64} & \underline{0.17} & \textbf{0.34} & \textbf{0.71} & \underline{0.15} & \textbf{0.26} & \textbf{0.54} & \underline{0.19} & \textbf{0.31} & \textbf{0.70}\\
 \hline
\end{tabular}}
\end{table*}
</code></pre>



<figure class="wp-block-image size-large"><img loading="lazy" width="1024" height="437" src="/wp-content/uploads/2022/06/截屏2022-06-02-11.08.08-1024x437.png" alt="" class="wp-image-601" srcset="/wp-content/uploads/2022/06/截屏2022-06-02-11.08.08-1024x437.png 1024w, /wp-content/uploads/2022/06/截屏2022-06-02-11.08.08-300x128.png 300w, /wp-content/uploads/2022/06/截屏2022-06-02-11.08.08-768x328.png 768w, /wp-content/uploads/2022/06/截屏2022-06-02-11.08.08-1536x655.png 1536w, /wp-content/uploads/2022/06/截屏2022-06-02-11.08.08-720x307.png 720w, /wp-content/uploads/2022/06/截屏2022-06-02-11.08.08-580x247.png 580w, /wp-content/uploads/2022/06/截屏2022-06-02-11.08.08-320x137.png 320w, /wp-content/uploads/2022/06/截屏2022-06-02-11.08.08.png 1566w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>使用命令 \setlength{\tabcolsep} 控制表格宽度</figcaption></figure>



<p>这种方式是我一直以来比较常用的方式，通过调整 \tabcolsep 的参数来控制表格整体的宽度，只需将\begin{tabular} 和 \end{tabuler} 包在其中即可。这种方式比较通用，可以用于将过窄的表格调整较宽，或将较宽的表格宽度调窄。但在表格宽度非常宽时容易失效，当表格仍然较宽不满足需求时，而列间间隔已无法改变来使得表格宽度继续变窄。此外，只改变列间距，而不改变字号和行高的做法，也可能会使得表格显得十分拥挤，因而也唱和命令 \renewcommand{\arraystretch} 一同使用。</p>



<h2>2. 使用包 adjustbox</h2>



<pre class="wp-block-code has-typology-txt-color has-text-color has-background language-python line-numbers" style="background-color:#f0f0f0" tabindex="0"><code lang="tex" class="language-tex">\begin{table*}[!htbp]
\centering
\caption{Quantitative depth SR results (in MAD) on Middlebury 2005 dataset. The best performance is displayed in bold, and the second best performance is marked in underline.}
\begin{adjustbox}{width=\linewidth}
\begin{tabular}{c|ccc|ccc|ccc|ccc|ccc|ccc}
\hline
\multirow{2}{*}{} & \multicolumn{3}{c|}{Art} & \multicolumn{3}{c|}{Books} & \multicolumn{3}{c|}{Dolls} & \multicolumn{3}{c|}{Laundry} & \multicolumn{3}{c|}{Mobius} & \multicolumn{3}{c}{Reindeer} \\
\cline{2-19}
 &$\times 4$  &$\times 8$  &  $\times 16$& $\times 4$ & $\times 8$ & $\times 16$ & $\times 4$ & $\times 8$ & $\times 16$ & $\times 4$ & $\times 8$ & $\times 16$ & $\times 4$ & $\times 8$ & $\times 16$ & $\times 4$ & $\times 8$ & $\times 16$ \\
 \hline
 CLMF & 0.76 & 1.44 & 2.87 & 0.28 & 0.51 & 1.02 & 0.34 & 0.60 & 1.01 & 0.50 & 0.80 & 1.67 & 0.29 & 0.51 & 0.97 & 0.51 & 0.84 & 1.55 \\
 JGF & 0.47 & 0.78 & 1.54 & 0.24 & 0.43 & 0.81 & 0.33 & 0.59 & 1.06 & 0.36 & 0.64 & 1.20 & 0.25 & 0.46 & 0.80 & 0.38 & 0.64 & 1.09\\
 TGV & 0.65 & 1.17 & 2.30 & 0.27 & 0.42 & 0.82 & 0.33 & 0.70 & 2.20 & 0.55 & 1.22 & 3.37 & 0.29 & 0.49 & 0.90 & 0.49 & 1.03 & 3.05\\
 CDLLC & 0.53 & 0.76 & 1.41 & 0.19 & 0.46 & 0.75 & 0.31 & 0.53 & 0.79 & 0.30 & 0.48 & 0.96 & 0.27 & 0.46 & 0.79 & 0.43 & 0.55 & 0.98\\
 PB & 0.79 & 0.93 & 1.98 & 0.16 & 0.43 & 0.79 & 0.53 & 0.83 & 0.99 & 1.13 & 1.89 & 2.87 & 0.17 & 0.47 & 0.82 & 0.56 & 0.97 & 1.89\\
 EG & 0.48 & 0.71 & \underline{1.35} & 0.15 & 0.36 & 0.70 & 0.27 & 0.49 & 0.74 & 0.28 & 0.45 & 0.92 & 0.23 & 0.42 & 0.75 & 0.36 & 0.51 & 0.95\\\hline
 SRCNN & 0.63 & 1.21 & 2.34 & 0.25 & 0.52 & 0.97 & 0.29 & 0.58 & 1.03 & 0.40 & 0.87 & 1.74 & 0.25 & 0.43 & 0.87 & 0.35 & 0.75 & 1.47 \\
 ATGVNet & 0.65 & 0.81 & 1.42 & 0.43 & 0.51 & 0.79 &0.41  & 0.52 & \textbf{0.56} & 0.37 & 0.89 & 0.94 & 0.38 &  0.45& 0.80 & 0.41 & 0.58 &1.01 \\
 MSG & 0.46 & 0.76 & 1.53 & 0.15 & 0.41 & 0.76 & 0.25 & 0.51 & 0.87 & 0.30 & 0.46 & 1.12 & 0.21 & 0.43 & 0.76 & 0.31 & 0.52 & 0.99\\
 DGDIE & 0.48 & 1.20 &2.44  & 0.30 & 0.58 & 1.02 & 0.34 & 0.63 & 0.93 & 0.35 & 0.86 & 1.56 & 0.28 & 0.58 & 0.98 & 0.35 & 0.73 &1.29 \\
 DEIN & 0.40 & 0.64 & \textbf{1.34} & 0.22 & 0.37 & 0.78 & 0.22 & 0.38 & 0.73 & 0.23 & \underline{0.36} & 0.81 & 0.20 & 0.35 & 0.73 & 0.26 & 0.40 & 0.80\\
 CCFN & 0.43 & 0.72 & 1.50 & 0.17 & 0.36 & 0.69 & 0.25 & 0.46 & 0.75 & 0.24 & 0.41 & \textbf{0.71} & 0.23 & 0.39 & 0.73 & 0.29 & 0.46 & 0.95\\
 GSRPT & 0.48 & 0.74 & 1.48 & 0.21 & 0.38 & 0.76 & 0.28 & 0.48 & 0.79 & 0.33 & 0.56 & 1.24 & 0.24 & 0.49 &  0.80& 0.31 & 0.61 &1.07 \\
CTKT & \textbf{0.25} & \textbf{0.53} & 1.44 & \textbf{0.11} & \underline{0.26} & \underline{0.67} & \textbf{0.16} & \underline{0.36} & 0.65 & \textbf{0.16} & \underline{0.36} & \underline{0.76} & \textbf{0.13} & \underline{0.27} & \underline{0.69} & \textbf{0.17} & \underline{0.35} & \underline{0.77}\\
BridgeNet (Ours)& \underline{0.30} & \underline{0.58} & 1.49 & \underline{0.14} & \textbf{0.24} & \textbf{0.51} &\underline{0.19}  & \textbf{0.34} & \underline{0.64} & \underline{0.17} & \textbf{0.34} & \textbf{0.71} & \underline{0.15} & \textbf{0.26} & \textbf{0.54} & \underline{0.19} & \textbf{0.31} & \textbf{0.70}\\
 \hline
\end{tabular}
\end{adjustbox}
\end{table*}
</code></pre>



<figure class="wp-block-image size-large"><img loading="lazy" width="1024" height="373" src="/wp-content/uploads/2022/06/截屏2022-06-02-11.18.25-1024x373.png" alt="" class="wp-image-602" srcset="/wp-content/uploads/2022/06/截屏2022-06-02-11.18.25-1024x373.png 1024w, /wp-content/uploads/2022/06/截屏2022-06-02-11.18.25-300x109.png 300w, /wp-content/uploads/2022/06/截屏2022-06-02-11.18.25-768x280.png 768w, /wp-content/uploads/2022/06/截屏2022-06-02-11.18.25-1536x559.png 1536w, /wp-content/uploads/2022/06/截屏2022-06-02-11.18.25-720x262.png 720w, /wp-content/uploads/2022/06/截屏2022-06-02-11.18.25-580x211.png 580w, /wp-content/uploads/2022/06/截屏2022-06-02-11.18.25-320x116.png 320w, /wp-content/uploads/2022/06/截屏2022-06-02-11.18.25.png 1566w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>使用包 adjustbox 控制表格宽度</figcaption></figure>



这种方式是最近在看一篇论文排版源码时学到的方法，Arxiv 要求上传 <span class="texhtml" style="font-family: 'CMU Serif', cmr10, LMRoman10-Regular, 'Latin Modern Math', 'Nimbus Roman No9 L', 'Times New Roman', Times, serif;">L<span style="text-transform: uppercase; font-size: 0.75em; vertical-align: 0.25em; margin-left: -0.36em; margin-right: -0.15em; line-height: 1ex;">a</span>T<span style="text-transform: uppercase; vertical-align: -0.25em; margin-left: -0.1667em; margin-right: -0.125em; line-height: 1ex;">e</span>X</span> 代码，可以从大家上传的排版文件学到很多。其使用方法是 \begin{adjustbox}{width=\linewidth} &#8230; \end{addustbox}，只需将 tabular 环境的表格内容包在其中即可。与第一种方式不同的是， adjustbox 在表格过长时表现得更好，可以同时调整列宽、行高和字号。但同样，在表格过小时，也会对表格进行放大，占据过多空间。<div style="margin-bottom:2.5em"></div>



<h2>3. 使用包 tabularx</h2>



<pre class="wp-block-code has-typology-txt-color has-text-color has-background language-python line-numbers" style="background-color:#f0f0f0" tabindex="0"><code lang="tex" class="language-tex">\usepackage{tabularx}
\usepackage{array}
\usepackage{ragged2e}
% 该命令用于控制 p{} 的情况
\newcolumntype{P}[1]{>{\RaggedRight\hspace{0pt}}p{#1}} % 使用过程中，将p{4cm}换成P{4cm}，小写改成大写即可！
% 该命令用于控制 X 的情况
\newcolumntype{Z}{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}X} % 使用过程中，将Z 换成 X，即可！
% 可利用 RaggedLeft Centering替换RaggedRight，实现靠右和居中

\begin{table*}[!htbp]
\centering
\caption{Quantitative depth SR results (in MAD) on Middlebury 2005 dataset. The best performance is displayed in bold, and the second best performance is marked in underline.}
\begin{tabularx}{\linewidth}{p{2.67cm} XXX|XXX|XXX|XXX|XXX|XXX}
\hline
\multirow{2}{*}{} & \multicolumn{3}{c|}{Art} & \multicolumn{3}{c|}{Books} & \multicolumn{3}{c|}{Dolls} & \multicolumn{3}{c|}{Laundry} & \multicolumn{3}{c|}{Mobius} & \multicolumn{3}{c}{Reindeer} \\
\cline{2-19}
 &$\times 4$  &$\times 8$  &  $\times 16$& $\times 4$ & $\times 8$ & $\times 16$ & $\times 4$ & $\times 8$ & $\times 16$ & $\times 4$ & $\times 8$ & $\times 16$ & $\times 4$ & $\times 8$ & $\times 16$ & $\times 4$ & $\times 8$ & $\times 16$ \\
 \hline
 CLMF & 0.76 & 1.44 & 2.87 & 0.28 & 0.51 & 1.02 & 0.34 & 0.60 & 1.01 & 0.50 & 0.80 & 1.67 & 0.29 & 0.51 & 0.97 & 0.51 & 0.84 & 1.55 \\
 JGF & 0.47 & 0.78 & 1.54 & 0.24 & 0.43 & 0.81 & 0.33 & 0.59 & 1.06 & 0.36 & 0.64 & 1.20 & 0.25 & 0.46 & 0.80 & 0.38 & 0.64 & 1.09\\
 TGV & 0.65 & 1.17 & 2.30 & 0.27 & 0.42 & 0.82 & 0.33 & 0.70 & 2.20 & 0.55 & 1.22 & 3.37 & 0.29 & 0.49 & 0.90 & 0.49 & 1.03 & 3.05\\
 CDLLC & 0.53 & 0.76 & 1.41 & 0.19 & 0.46 & 0.75 & 0.31 & 0.53 & 0.79 & 0.30 & 0.48 & 0.96 & 0.27 & 0.46 & 0.79 & 0.43 & 0.55 & 0.98\\
 PB & 0.79 & 0.93 & 1.98 & 0.16 & 0.43 & 0.79 & 0.53 & 0.83 & 0.99 & 1.13 & 1.89 & 2.87 & 0.17 & 0.47 & 0.82 & 0.56 & 0.97 & 1.89\\
 EG & 0.48 & 0.71 & \underline{1.35} & 0.15 & 0.36 & 0.70 & 0.27 & 0.49 & 0.74 & 0.28 & 0.45 & 0.92 & 0.23 & 0.42 & 0.75 & 0.36 & 0.51 & 0.95\\\hline
 SRCNN & 0.63 & 1.21 & 2.34 & 0.25 & 0.52 & 0.97 & 0.29 & 0.58 & 1.03 & 0.40 & 0.87 & 1.74 & 0.25 & 0.43 & 0.87 & 0.35 & 0.75 & 1.47 \\
 ATGVNet & 0.65 & 0.81 & 1.42 & 0.43 & 0.51 & 0.79 &0.41  & 0.52 & \textbf{0.56} & 0.37 & 0.89 & 0.94 & 0.38 &  0.45& 0.80 & 0.41 & 0.58 &1.01 \\
 MSG & 0.46 & 0.76 & 1.53 & 0.15 & 0.41 & 0.76 & 0.25 & 0.51 & 0.87 & 0.30 & 0.46 & 1.12 & 0.21 & 0.43 & 0.76 & 0.31 & 0.52 & 0.99\\
 DGDIE & 0.48 & 1.20 &2.44  & 0.30 & 0.58 & 1.02 & 0.34 & 0.63 & 0.93 & 0.35 & 0.86 & 1.56 & 0.28 & 0.58 & 0.98 & 0.35 & 0.73 &1.29 \\
 DEIN & 0.40 & 0.64 & \textbf{1.34} & 0.22 & 0.37 & 0.78 & 0.22 & 0.38 & 0.73 & 0.23 & \underline{0.36} & 0.81 & 0.20 & 0.35 & 0.73 & 0.26 & 0.40 & 0.80\\
 CCFN & 0.43 & 0.72 & 1.50 & 0.17 & 0.36 & 0.69 & 0.25 & 0.46 & 0.75 & 0.24 & 0.41 & \textbf{0.71} & 0.23 & 0.39 & 0.73 & 0.29 & 0.46 & 0.95\\
 GSRPT & 0.48 & 0.74 & 1.48 & 0.21 & 0.38 & 0.76 & 0.28 & 0.48 & 0.79 & 0.33 & 0.56 & 1.24 & 0.24 & 0.49 &  0.80& 0.31 & 0.61 &1.07 \\
CTKT & \textbf{0.25} & \textbf{0.53} & 1.44 & \textbf{0.11} & \underline{0.26} & \underline{0.67} & \textbf{0.16} & \underline{0.36} & 0.65 & \textbf{0.16} & \underline{0.36} & \underline{0.76} & \textbf{0.13} & \underline{0.27} & \underline{0.69} & \textbf{0.17} & \underline{0.35} & \underline{0.77}\\
BridgeNet (Ours)& \underline{0.30} & \underline{0.58} & 1.49 & \underline{0.14} & \textbf{0.24} & \textbf{0.51} &\underline{0.19}  & \textbf{0.34} & \underline{0.64} & \underline{0.17} & \textbf{0.34} & \textbf{0.71} & \underline{0.15} & \textbf{0.26} & \textbf{0.54} & \underline{0.19} & \textbf{0.31} & \textbf{0.70}\\
 \hline
\end{tabularx}
\end{table*}
</code></pre>



<figure class="wp-block-image size-large"><img loading="lazy" width="1024" height="426" src="/wp-content/uploads/2022/06/截屏2022-06-02-12.11.06-1024x426.png" alt="" class="wp-image-605" srcset="/wp-content/uploads/2022/06/截屏2022-06-02-12.11.06-1024x426.png 1024w, /wp-content/uploads/2022/06/截屏2022-06-02-12.11.06-300x125.png 300w, /wp-content/uploads/2022/06/截屏2022-06-02-12.11.06-768x320.png 768w, /wp-content/uploads/2022/06/截屏2022-06-02-12.11.06-1536x640.png 1536w, /wp-content/uploads/2022/06/截屏2022-06-02-12.11.06-720x300.png 720w, /wp-content/uploads/2022/06/截屏2022-06-02-12.11.06-580x241.png 580w, /wp-content/uploads/2022/06/截屏2022-06-02-12.11.06-320x133.png 320w, /wp-content/uploads/2022/06/截屏2022-06-02-12.11.06.png 1566w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>使用包 tabularx  控制表格宽度</figcaption></figure>



<p>包 tabularx 的使用和 adjustbox 相差无几，其作用是可以自动计算列宽，而不会改变行高等，更适用于宽度较窄的表格的格式设置，档表格过宽时，内容会过于拥挤。除此以外，表格内容的居中、靠左、靠右等也比较复杂。</p>



<p>综上，依据使用经验来看，当表格过窄时，宜使用命令 \setlength{\tabcolsep} 和包 tabularx，而当表格过宽时，宜使用包 adjustbox。 </p>
]]></content:encoded>
					
					<wfw:commentRss>/2022/06/02/latex_table/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>基于 MacOS 搭建 WordPress</title>
		<link>/2022/05/22/macos_wordpress/</link>
					<comments>/2022/05/22/macos_wordpress/#respond</comments>
		
		<dc:creator><![CDATA[Tang]]></dc:creator>
		<pubDate>Sun, 22 May 2022 10:29:52 +0000</pubDate>
				<category><![CDATA[Technology]]></category>
		<guid isPermaLink="false">/?p=555</guid>

					<description><![CDATA[WordPress 是一款通过使用 PHP 语言开发的博客平台，开发者可以通过 WordPress 搭建属于自己的个人博客平台，本文基于 Mac 操作系统搭建 WordPress 个人站点，并将静态文件部署到 Github。]]></description>
										<content:encoded><![CDATA[
<p class="has-drop-cap">WordPress 是一款通过使用 PHP 语言开发的博客平台，开发者可以通过 WordPress 搭建属于自己的个人博客平台，本文基于 Mac 操作系统搭建 WordPress 个人站点，并将静态文件部署到 Github。</p>



<h2>一、搭建本地开发环境</h2>



<p>Mac 操作系统下，通过 MAMP 搭建本地开发环境，它是由苹果 OSX 系统上集成的 Apache、Macintosh、MySQL 和 PHP 等软件包，可以在本地模拟网络空间，下载链接 <a href="https://xie.infoq.cn/link?target=https%3A%2F%2Fwww.mamp.info%2Fen%2Fmac%2F">https://www.mamp.info/en/mac/</a> 。</p>



<figure class="wp-block-image"><img src="https://static001.geekbang.org/infoq/0a/0a49304b533a66a5893e673d766f74f9.jpeg?x-oss-process=image/resize,p_80/auto-orient,1" alt=""/></figure>



<p>下载完 MAMP 安装包，直接解压打开，双击安装，点击“下一步”，安装 MAMP 之后，打开 MAMP 版本，Pro 版本是需要收费的，选择免费的 MAMP 即可。</p>



<p>点击“Preferences…”—&gt;”Web Server”—&gt;”Document Root” 重新选择网站重新目录，该目录存放网站程序。</p>



<h2>二、安装网站程序</h2>



<p>在 <a rel="noreferrer noopener" href="https://cn.wordpress.org/" target="_blank">WordPress 官网</a>下载 WordPress。</p>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.cmk.red/assets/experience/1c552356/10.png" alt=""/><figcaption>① 解压 WordPress 到设置的 Document root</figcaption></figure></div>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.cmk.red/assets/experience/1c552356/05.png" alt=""/><figcaption>① Start</figcaption></figure></div>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.cmk.red/assets/experience/1c552356/07.png" alt=""/><figcaption>① phpMyAdmin 或在页面顶部 Menu 的 Tools 中可以找到</figcaption></figure></div>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.cmk.red/assets/experience/1c552356/08.png" alt=""/><figcaption>① 新建</figcaption></figure></div>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.cmk.red/assets/experience/1c552356/09.png" alt=""/><figcaption>① 输入数据库名称<br>② 创建</figcaption></figure></div>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.cmk.red/assets/experience/1c552356/11.png" alt=""/><figcaption>在浏览器中打开 localhost/wordpress 或 localhost:8888<br>① 现在就开始</figcaption></figure></div>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.cmk.red/assets/experience/1c552356/12.png" alt=""/><figcaption>① 输入数据库名称<br>② 输入 root<br>③ 输入 root<br>④ 提交</figcaption></figure></div>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.cmk.red/assets/experience/1c552356/13.png" alt=""/><figcaption>① 运行安装程序</figcaption></figure></div>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.cmk.red/assets/experience/1c552356/14.png" alt=""/><figcaption>① 输入站点标题<br>② 输入用户名<br>③ 输入密码<br>④ 输入您的电子邮件地址<br>⑤ 可选<br>⑥ 安装 WordPress</figcaption></figure></div>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.cmk.red/assets/experience/1c552356/15.png" alt=""/><figcaption>① 登录</figcaption></figure></div>



<div class="wp-block-image"><figure class="aligncenter"><img src="https://www.cmk.red/assets/experience/1c552356/16.png" alt=""/><figcaption>安装完成</figcaption></figure></div>



<h2>三、部署到 Github</h2>



<p>Github Pages 是面向用户、组织和项目开放的公共静态页面搭建托管服务，站点可以被免费托管在 Github 上，我们可以选择使用 Github Pages 默认提供的域名 github.io 或者自定义域名来发布站点。Github Pages 支持自动利用 Jekyll 生成站点，也同样支持纯 HTML 文档。因此，想要将搭建的个人站点托管在 Github，就需要将其静态化。</p>



<p>插件市场搜索 static，下载插件 Simply Static，下载量最高，使用也比较方便，但缺点是不支持文章 url  有中文名，可以在设置-固定链接中进行修改。此外，还可以在设置中选择下载生成的静态文件压缩包或直接将静态文件生成到指定路径。然后，就可以将生成的文件部署到 Github，并通过域名访问。</p>



<p>Github Page 的创建可参考 <a rel="noreferrer noopener" href="https://blog.csdn.net/Tang_Chuanlin/article/details/83626545" target="_blank">https://blog.csdn.net/Tang_Chuanlin/article/details/83626545</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>/2022/05/22/macos_wordpress/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>百度安全验证深度学习解决方案</title>
		<link>/2022/05/21/baidu-rot-validate/</link>
					<comments>/2022/05/21/baidu-rot-validate/#respond</comments>
		
		<dc:creator><![CDATA[Tang]]></dc:creator>
		<pubDate>Sat, 21 May 2022 15:50:24 +0000</pubDate>
				<category><![CDATA[Computer Vision]]></category>
		<guid isPermaLink="false">/?p=518</guid>

					<description><![CDATA[利用神经网络（考虑模型、数据集的大小以及模型的感受野）在数据集上进行训练，直接预测需要滑动的距离。由于百度安全验证的角度并不是整数变化的，滑动距离与角度的变化也不是一一对应的，因此相对于预测角度而言，直接预测滑动距离更加准确、便捷。且滑动距离的类别相比较于而言要少，从而使得模型的参数也更少。此外，因为模型的目的是能足够准确地预测滑动距离，从而使得自动化程序模拟验证，因此，应该使得模型尽可能多地在现有数据集上学习。综上，考虑到真实场景的验证图片与获得的图片存在一定的差异（即使是相同的图片，也会受到不同程度的噪声干扰，如水印等），不再对数据集进行训练集与测试集的划分。]]></description>
										<content:encoded><![CDATA[
<p class="has-drop-cap">在通过百度关键词搜索进行爬虫的过程中，会遇到进入百度安全验证页面的情况。随着访问次数的的增加，进入安全验证页面的概率也随之增大，且这种情况并不能通过请求头加入 Accept 和引入随机 UA 来解决（代理是否能解决这一问题未得到充分验证，以我的尝试来看并不能有效解决）。</p>



<p>在尝试过上述的几种方法来反“反爬”的过程中，发现一旦可以通过安全验证，在后续的爬虫过程中，可观察时间内并不会再次进入安全验证页面。既然“堵”不适合我解决这一问题，就只有利用“疏”的思路制定解决方案。</p>



<p>百度安全验证页面采用拖动滑块使页面中的图片角度为正确方向来判断是否为“自动程序”在控制浏览器。相较于一般的字符识别等验证方案具有一定的难度，直观表现在没有（或者几乎没有）现有的 API 供应商在提供这样的服务。</p>



<p>网络上现有的、基于图像处理或计算机视觉的解决方案主要分为传统方法和深度学习方法。传统方法通过对图像进行处理、建模来建立正确方向图像和不同角度图像的映射，再通过对图像进行哈希处理判定与页面上的图像最相似的图像，从而在映射关系中获得旋转角度。这种方法形成的“关系模型”会随着图库数量的增大而不断增大，且哈希编码来查找相似图像的方法鲁棒性较差。现有的基于深度学习的方法利用在 Google Street View dataset 训练的 RotNet 来预测图片旋转角度，经试验在类街景的测试图片上识别成功率较高。但由于缺乏百度安全验证页面中采用的人像、风景等多类样本，难以运用到实际使用中。除此以外，还有其他因素导致了利用该模型难以通过安全验证。</p>



<p>综上，在参考现有文章的基础上，总结出以下基于深度学习的方法：</p>



<blockquote class="wp-block-quote"><p>目标：</p></blockquote>



<p>识别图片角度，推算出对应滑动距离，模拟滑动。</p>



<blockquote class="wp-block-quote"><p>实现：</p></blockquote>



<ol><li>获得原始图片数据集：循环访问百度搜索页面从而进入百度安全验证页面，抓取图片1500张，获得大量重复图片。对这些图片进行筛选，获得不重复图片144张（在前期实验的过程中发现安全验证页面易出现重复图片，推测用于验证的图片数据集规模较）；</li></ol>



<figure class="wp-block-image"><img src="https://img-blog.csdnimg.cn/5124b0ad94494ba8b54c8dca0b7e6c16.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAVGFuZzU2MTg=,size_20,color_FFFFFF,t_70,g_se,x_16#pic_center" alt="在这里插入图片描述"/></figure>



<ol start="2"><li>制作数据集：生成各个角度的图片，每个不同的图片均有360张不同角度的照片，标记正向图，根据现有图片名称序列计算不同角度照片相对于正向图片的相对角度，重新命名从而建立数据集；</li></ol>



<figure class="wp-block-image"><img src="https://img-blog.csdnimg.cn/17cf39e2bd114730b196357bff83c45d.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAVGFuZzU2MTg=,size_20,color_FFFFFF,t_70,g_se,x_16#pic_center" alt="在这里插入图片描述"/></figure>



<figure class="wp-block-image"><img src="https://img-blog.csdnimg.cn/1eba81026b4749368832d211bf0f2d37.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAVGFuZzU2MTg=,size_20,color_FFFFFF,t_70,g_se,x_16#pic_center" alt="在这里插入图片描述"/></figure>



<ol start="3"><li>生成规则：根据滑动距离与图片旋转角度的关系形成滑动规则（按照滑动距离 $o=angle \times 360 \times b$ 的规则来预测角度是不准确的，所以通过在安全验证页面逐单位距离滑动记录角度与滑动距离的关系）；</li><li>模型训练：利用神经网络（考虑模型、数据集的大小以及模型的感受野）在数据集上进行训练，直接预测需要滑动的距离。由于百度安全验证的角度并不是整数变化的，滑动距离与角度的变化也不是一一对应的，因此相对于预测角度而言，直接预测滑动距离更加准确、便捷。且滑动距离的类别相比较于而言要少（也可以考虑做成回归任务），从而使得模型的参数也更少。此外，因为模型的目的是能足够准确地预测滑动距离，从而使得自动化程序模拟验证，因此，应该使得模型尽可能多地在现有数据集上学习。综上，考虑到真实场景的验证图片与获得的图片存在一定的差异（即使是相同的图片，也会受到不同程度的噪声干扰，如水印等），不再对数据集进行训练集与测试集的划分。</li></ol>



<blockquote class="wp-block-quote"><p>性能：</p></blockquote>



<p>推理快、预测准（普遍最多在三次验证中可通过，根据实际操作和 b 站视频来看，人为通过安全验证的难度也相对较大）</p>



<blockquote class="wp-block-quote"><p>操作</p></blockquote>



<p>python 开发可以参考 <a href="https://github.com/ShortCJL/RotateCode" target="_blank" rel="noreferrer noopener">https://github.com/ShortCJL/RotateCode</a><br>java 开发可先将训练获得的模型进行转化</p>



<pre class="wp-block-code has-typology-txt-color has-text-color has-background" style="background-color:#f0f0f0"><code lang="python" class="language-python line-numbers">import torch
import torchvision
import torch.nn as nn

model = # instance of your model
model.load_state_dict(torch.load("your model.pth")["model_state_dict"])

# Switch the model to eval model
model.eval()

# An example input you would normally provide to your model's forward() method.
example = torch.rand(1, 3, 128, 128)

# Use torch.jit.trace to generate a torch.jit.ScriptModule via tracing.
traced_script_module = torch.jit.trace(model, example)

# Save the TorchScript model
traced_script_module.save("your model.pt")</code></pre>



<p>之后，便可通过 DJL 加载模型并作出预测，并借助其他工具来操作浏览器实现验证（为不限制大家思路，在此不放出我的实现代码）。</p>



<blockquote class="wp-block-quote"><p>代码</p></blockquote>



<p>欢迎大家 star <a href="https://github.com/Tang1705/Baidu-Rot-Validate" target="_blank" rel="noreferrer noopener">https://github.com/Tang1705/Baidu-Rot-Validate</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>/2022/05/21/baidu-rot-validate/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>一封写给过去和未来的信</title>
		<link>/2022/05/05/page/</link>
					<comments>/2022/05/05/page/#respond</comments>
		
		<dc:creator><![CDATA[Tang]]></dc:creator>
		<pubDate>Thu, 05 May 2022 09:05:00 +0000</pubDate>
				<category><![CDATA[Writing]]></category>
		<guid isPermaLink="false">/?p=568</guid>

					<description><![CDATA[在五年之约过期的第一天，我想写下一封信，无关现在，寄给过去和未来。 五年前的高考前夕，也就是在2017年的5月 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<div class="wp-block-cover alignfull rocket-lazyload lazyloaded" style="background-position: 50% 50%; background-image: url(&quot;/wp-content/uploads/2022/05/kite-scaled.jpg&quot;);" data-ll-status="loaded"><div class="wp-block-cover__inner-container"><p class="has-text-align-center has-large-font-size"></p></div></div>



<p>在五年之约过期的第一天，我想写下一封信，无关现在，寄给过去和未来。</p>



<p>五年前的高考前夕，也就是在2017年的5月4日，我的高中为我们举办了一场仪式感满满的成人礼，也是那一天，我们每人将一封写给未来的信放入了时间胶囊中，定下了所谓的“五年之约”，约定五年后一起打开这段尘封了五年的故事。时间过得很快，如今已然从当年的亲历者成长为第三视角的观礼者，而写下这段故事的人儿，有的已经在不同的岗位摸爬滚打，有的还在校园中打怪升级。去年由于本科毕业，也同几位高中老师、同学有过相聚，老师关心的话题也同大多故事里一样，多了些对儿女情长的挂念。想来有趣，上学时或许最怕学生谈恋爱的一个群体，如今也加入了催你找男女朋友的队伍。</p>



<p>至于信里到底写了什么，如今倒也记不清了，只依稀记得当时按照写作文的套路理了个框架，大抵是告诫未来不要忘记一路以来的努力，畅想继续拼搏五年之后的一番光景……自是不必说这篇短短时间写的信了，就是那些背了一年的诗词公式，也会在午夜梦回高中时因无法记起而心跳加快。但和本科论文致谢放在一起来看，我倒一直是个不忘感谢自己的人哈。虽然这封信的内容浑忘了，但我还是希望写一些东西给这位因疫情而耽搁了见面的老朋友，作为给他的见面礼。</p>



<p>往昔分飞，本期暂别，何因一阻，遂即经年。这封信里，我想和你讲讲你没经历的故事，这正是“你我”畅想的未来，而过去的回忆到时候有你来揭开。我想说，是的，记忆中有计划过的事现在都一步步走进了现实，当然也许会有些偏差。离开了生活了十几年的城市，到北京上大学、有好好读书、也有和朋友见面、更认识了好多好多的朋友，然后，现在的我毕业了。除了当初想做的那些事，比如，不要把眼界禁锢在小小的一方校园，去把与世界交流的渠道打开；又或者是要有一些理财的规划；再或者是学一个双学位……少年啊，一贯有很多的想法和梦，就像我们永远会相信光的存在，那是从小到大对正义和勇敢的向往。而梦，是我们对成长的不懈追求。一路上，我也看到了很多新的风景，纵使不能准确说出有丝分裂的历程，但我学会了如何让计算机分辨手写数字，你看这是成长过程中知识的迭代更新。我也和朋友一起吹过青海湖的风、看过沙漠的星空和日出，毕竟读万卷书不如行万里路。所以啊，我们并没有忘记一路以来的努力，一直在一步步成为年少时期待的样子。</p>



<p>芳信远临，还同面叙，批文解封，企望成劳。这封信既写给了五年前，也想写给五年后，作为又一个“五年之约”。疫情横行的时日，出行的脚步被迫停下，但身体和灵魂总有一个在路上。随着人工智能、第五代移动通信技术及虚拟现实、增强现实等技术的不断发展，元宇宙的概念在近一年来被推上了风口浪尖。疫情时代，元宇宙的兴起仿佛是黑暗中骤然亮起的明灯。我对她的幻想，是目光漫步在技术构建的现实映射，哪怕居家隔离，也能坐船游遍桂林山水；是身心沉浸在天涯若比邻的朋友际会，哪怕风险重重，也能戴上设备把酒言欢。当然，我也有想过最想要的生活态度，那个无数次被我谈起的幸福生活，是梦，亦是对成长的不懈追求。无论如何，最起码，要租住在海边吧，在海边 meeting，哪怕写的全是 bug 我都会开心的好嘛，吹吹海风什么烦恼都没有了。所以啊，往事暗沉不可追，来日之路光明灿烂。</p>



<p>说来无关现在，但怎能真的无关。于过去而言，现在是过去无比想到达的未来；于未来而言，现在又是无比怀念的过去。站在现在，我无比期待下一个五年。</p>
]]></content:encoded>
					
					<wfw:commentRss>/2022/05/05/page/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>世界，您好！</title>
		<link>/2022/05/01/hello-world/</link>
					<comments>/2022/05/01/hello-world/#comments</comments>
		
		<dc:creator><![CDATA[Tang]]></dc:creator>
		<pubDate>Sun, 01 May 2022 13:03:50 +0000</pubDate>
				<category><![CDATA[未分类]]></category>
		<guid isPermaLink="false">/?p=1</guid>

					<description><![CDATA[欢迎使用WordPress。这是您的第一篇文章。编辑或删除它，然后开始写作吧！]]></description>
										<content:encoded><![CDATA[
<p>欢迎使用WordPress。这是您的第一篇文章。编辑或删除它，然后开始写作吧！</p>
]]></content:encoded>
					
					<wfw:commentRss>/2022/05/01/hello-world/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
