查看本系列文章合集,请点击这里。
为了对蒙特卡罗方法有一个直观的印象,本文再举一个实例(计算定积分),以说明蒙特卡罗方法的用途。
- 什么是定积分
对于一个给定的正实值函数 \(f(x)\) ,它在一个实数区间 [a,b]上的定积分 \(\int_a^b {f(x)dx} \) 可以理解为在 OXY 坐标平面上,由曲线 (x,f(x))、直线 x=a,x=b以及x轴围成的曲边梯形的面积值。
蒙特卡罗(洛)方法(Monte Carlo method),也称统计模拟方法,是1940年代中期由于科学技术的发展和电子计算机的发明,而提出的一种以概率统计理论为指导的数值计算方法。是指使用随机数来解决很多计算问题的方法。
现在(2019.07) Anaconda官网上下载到的Anaconda安装包,已经对应的是Python 3.7版本了,如果想要安装Python 3.6版,那么有如下几种方法:
最近我的Ubuntu台式机每隔两三天就会进入一种硬盘狂读+点击鼠标无反应的死机状态,由于SSD已经用了很多年,我非常担心它会随时挂掉,导致数据丢失的惨剧发生,于是我提前预防,买了块同品牌、同容量的SSD来替换它。但是从头开始重装系统+配置各种软件的过程实在太痛苦了,所以我决定做一次全盘复制,这样就能省去很多时间。
如果一个JSON字符串里有一个字段,它的值又是一个完整的JSON字符串,那么这时候,它可能会含有转义字符。举个例子,我们有一个文件 codelast.json,它的内容为一行字符串:
{"aaa":"{\"ccc\":\"ccc\",\"ddd\":\"ddd\"}","bbb":{"ccc":"ccc","ddd":"ddd"}}
现在要用Jackson解析它为一个Java对象,怎么做?
与Ubuntu系统下的配置过程比较相似,先安装Privoxy:
brew install privoxy
再修改其配置文件 /usr/local/etc/privoxy/config,在文件末尾添加如下内容:
在Ubuntu下,除了浏览器之外,为了能在系统全局层面上自动使用代理访问那些“不存在的网站”,有一个常用的做法就是,在Chrome的SwitchyOmega插件里的“自动切换”情景模式下“导出PAC”,得到一个PAC文件,放在磁盘的某个路径下(假设为:/home/codelast/OmegaProfile__.pac),然后在Ubuntu系统的网络设置里如下设置:
今天在MAC OS上用 brew install openssh 之后,再用iTerm2打开一个新窗口的时候,都会提示以下错误:
ssh-add: illegal option -- K
usage: ssh-add [options] [file …]
在我的例子中,是由于安装openssh之后装上了一个新的ssh-add程序,和MAC OS原来自带的ssh-add有些不一样,MAC自带的ssh-add程序包含-K参数,而openssh带的那个ssh-add没有-K参数,因此不能识别,从而造成了错误。
Ubuntu不知道什么原因,不能用 apt-get install 安装任何软件了,并且在屏幕上输出海量错误信息,非常迷惑人,例如下面这一例:
insserv: Starting vpnagentd_init depends on plymouth and therefore on system facility `$all' which can not be true!insserv: There is a loop between service vpnagentd_init and mountkernfs if startedinsserv: loop involving service mountkernfs at depth 1insserv: Starting vpnagentd_init depends on plymouth and therefore on system facility `$all' which can not be true!......
insserv: Starting vpnagentd_init depends on plymouth and therefore on system facility `$all' which can not be true!insserv: There is a loop between service vpnagentd_init and dns-clean if startedinsserv: loop involving service dns-clean at depth 1......
insserv: Starting vpnagentd_init depends on plymouth and therefore on system facility `$all' which can not be true!insserv: exiting now without changing boot order!update-rc.d: error: insserv rejected the script headerdpkg: error processing package binfmt-support (--configure):subprocess installed post-installation script returned error exit status 1No apport report written because MaxReports is reached alreadyProcessing triggers for initramfs-tools (0.122ubuntu8.10) ...update-initramfs: Generating /boot/initrd.img-4.13.0-32-genericErrors were encountered while processing:udevgrub-commongrub2-commongrub-pc-bingrub-pcresolvconfbinfmt-supportE: Sub-process /usr/bin/dpkg returned an error code (1)
查看本系列文章合集,请点击这里。
为了对蒙特卡罗方法有一个直观的印象,我们先举一个实例(计算圆周率 \(\pi \) ),让从来没有接触过蒙特卡罗方法的人产生“原来这就是Monte Carlo”的感觉,以减少刚开始学习的困惑。
圆周率 \(\pi \) 可以怎么计算?其中一个“常规”的方法就是利用 \(\pi \) 的莱布尼茨公式:
\(\frac{\pi }{4} = \sum\limits_{n = 0}^\infty {\frac{{{{\left( { - 1} \right)}^n}}}{{2n + 1}}} = 1 - \frac{1}{3} + \frac{1}{5} - \frac{1}{7} + \frac{1}{9} - \cdots \)
不断增大 \(n\) 的值,就能越来越逼近 \(\frac{\pi }{4}\)
OS:Ubuntu 16.04.3 LTS
JDK:1.8.0_60
Selenium:3.0.0
Chrome:61.0.3163.100
本文描述了用JAVA编程控制Selenium时,遇到的“failed to change window state to maximized, current state is normal”错误的解决方法。