科学网

 找回密码
  注册

tag 标签: functions

相关帖子

版块 作者 回复/查看 最后发表

没有相关内容

相关日志

Functions for continuous truncated Pareto distributions
laijiangshan 2016-12-25 21:12
#### Functions for continuous truncated Pareto distributions # by Lai jiangshan # dtpareto Probability density # ptpareto Probability distribution (CDF) # qtpareto Quantile function # rtpareto Random variable generation # Probability density of truncated Pareto distributions # Gives NA on values below the lower # Input: Data vector, lower threshold,upper threshold, scaling exponent, log flag # Output: Vector of (log) probability densities dtpareto - function(x, lower,upper, exponent, log=FALSE) { # Avoid doing limited-precision arithmetic followed by logs if we want # the log! if (!log) { prefactor - (1-exponent)/(upper^(1-exponent)-lower^(1-exponent)) f - function(x) {prefactor*(x)^(-exponent)} } else { prefactor.log - log((1-exponent)/(upper^(1-exponent)-lower^(1-exponent))) f - function(x) {prefactor.log -exponent*log(x)} } d - ifelse(xlower,NA,f(x)) return(d) } # Cumulative distribution function of the Pareto distributions # Gives NA on values threshold # Input: Data vector, lower threshold,upper threshold scaling exponent, usual flags # Output: Vector of (log) probabilities ptpareto - function(x, lower, upper,exponent, lower.tail=TRUE, log.p=FALSE) { if ((!lower.tail) (!log.p)) { f - function(x) {1-(x^(1-exponent)-lower^(1-exponent))/(upper^(1-exponent)-lower^(1-exponent))} } if ((lower.tail) (!log.p)) { f - function(x) { (x^(1-exponent)-lower^(1-exponent))/(upper^(1-exponent)-lower^(1-exponent))} } if ((!lower.tail) (log.p)) { f - function(x) {log(1-(x^(1-exponent)-lower^(1-exponent))/(upper^(1-exponent)-lower^(1-exponent)))} } if ((lower.tail) (log.p)) { f - function(x) {log((x^(1-exponent)-lower^(1-exponent))/(upper^(1-exponent)-lower^(1-exponent)))} } p - ifelse(x lower, NA, f(x)) return(p) } # Quantiles of Pareto distributions # Input: vector of probabilities, lower threshold,upper threshold,scaling exponent, usual flags # Output: Vector of quantile values qtpareto - function(p, lower,upper, exponent, lower.tail=TRUE, log.p=FALSE) { if (log.p) { p - exp(p) } if (lower.tail) { p - 1-p } # This works, via the recycling rule # q-(p^(1/(1-exponent)))*lower q - (p*(upper^(1-exponent)-lower^(1-exponent))+lower^(1-exponent))^(1/(1-exponent)) return(q) } # Generate Pareto-distributed random variates # Input: Integer size, lower threshold,upper threshold scaling exponent # Output: Vector of real-valued random variates rtpareto - function(n, lower,upper, exponent) { # Using the transformation method, because we know the quantile function # analytically # Consider replacing with a non-R implementation of transformation method ru - runif(n) r-qtpareto(ru,lower,upper,exponent) return(r) }
3093 次阅读|0 个评论
Python 3: Module math - mathematical functions
haibaraxx 2016-11-17 22:35
import math # math.floor(x) returns the floor of x as a float, the largest integer value less than or equal to x. math.floor(9.2) 9.0 # math.sqrt(x) returns the square root of x. math.sqrt(81) 9.0 # math.pow(x,y) returns x raised to the power y. math.pow(2,3) 8.0 # math.log10(x) returns the base-10 logarithm of x. math.log10(100) 2.0 # math.exp(x) returns e**x. math.exp(2) 7.38905609893065 # check if the float x is a NaN math.isnan(x) # equivalent to the output of float('nan'). math.nan # python3 nan math. pi 3.141592653589793 math. e 2.718281828459045
个人分类: Python|2610 次阅读|0 个评论
Why do injective holomorphic functions have nonzero derivati
yuewenxiong 2015-10-7 23:48
1. Why do injective holomorphic functions have nonzero derivative 2. proof-that-1-1-analytic-functions-have-nonzero-derivative 3. If p(z)p(z) is an injective polynomial
个人分类: 黎曼曲面|1800 次阅读|0 个评论
科普一下网络绑票背后的技术(一)
热度 24 lujiangxiao 2015-2-2 12:01
过圣诞过 年乱哄哄的,好久没静下心写科普了。好容易等到一个不用打牌的周末,写点什么呢? 据 说写科普的最高境界是写自己不懂的科学, 咱就挑战自己,向这个高度靠拢一下吧。 我要力求做到 科普的基本要求:把复杂的原理用简单的几句话正确地讲出来。 -------- 一 个恐怖的故事 那天 (01/24/1015) 听到美国国家公共 电 台( NPR )里 讲的 一 个恐怖故事:一个人的 计 算机中了病毒,把他所有的文件, 电邮 ,照片都被病毒加了密,完全没法 读 了。勒索者 说 你可以交勒索 费 ( Ransomware) 把它 们赎 回来。 由于 计 算机加密后是目前技 术 不可解的,受害者只好乖乖交 钱 , 赎 回一个密 码 ,解开了他所有文件。 NPR 的 这 个 节 目[ 1 ]做得满拼的 , 为 了加深听众印象,他 们专门 找了一个受害者当 场电话 叩 应 : 这 是一个中招的警察局,里面的一个警察用局里的机器看网,不知点了个什么中了毒。立刻把警局所有文件 锁 住了,里面包括 15 年来所有 办 案文件,案件照片,口供等等。 这 些重要文件肯定是有 备 份的,可是 备 份机也同 时 被感染了,所以把所有 备 份都同 样 加了密。 警局抓狂了,找来 FBI ,然后 FBI 说这个加密和米国国安局水平是一样的,没解。 您 还 是 认 栽, 按 找勒索者的要求付 赎 票 费吧。你们的文件比原则更重要,等等等等。于是老革命遇上新问题,警察蜀黍硬着头皮上网学买网币( bitcoin),然后乖乖向小毛贼交钱,拿回所有文件。 好,这使我很感兴趣了。这种数字勒索背后究竟是什么技术呢?为啥能一个穷小子做案后,倾国王的千军万马,全部经费解不开呢?这道理实际很简单,就是正运算容易,逆运算难。比如算术里的正运算乘法,其逆运算是除法。乘法有口诀,但是除法就没有。小学老师教我们做除法的时候用“试商”就是先假想一个答案,然后用乘法验证其是否对。这样用两个数通过乘法算出一个结果,要把结果通过逆运算还原成那两个数,就要花费更多的时间。如果两个乘数都很大,逆运算就需要世界最强的计算机花一万年才能完成,就算理论上肯定能算出来,实际上却行不通,这数字基本就勒索成功了。 逆运算为什么这样难 什么逆运算可以这么难呢?比如咱小学学过的质因数分解,是乘法的逆运算。质因数分解就是一个数分解成几个相乘的质数,比如把1457分解成 37 乘以 41。我们可以用一个计算器把两个质数很快地乘起来,比如把两个质数,1000000000193 和999999999673 相乘得到999999999865999999936889,这需要的时间可以忽略不计,但把999999999865999999936889,分解成上面两个质数,需要的时间就长多了。所以当两个质数都很大,分解解质因数的计算时间就与数字长度的指数成正比,可以轻易长到几百年几万年,谁都不能容忍的地步。这样如果用其中一个质数作为密码,别人虽然知道两数之积,也没办法找出这个质数。当然数学家也在钻研分解质因数的捷径,而且已经钻研出很多小把戏,可以很快地分解比较特殊的质数对。所以在选择两个质数的时候必须避开一些可以被这些把戏攻破的质数对。上述的网络绑架的病毒就是利用类似的,数学上还没解决的“硬难题”(harsh functions) 方法进行加密, 造成只有加密者可解的方法。节目上说每年至少有几百万计算机中招。大多数人是付钱消灾。 我下面顺便科普一点信息加密和密码学吧。所谓加密就是把咱们说的大白话通过一个变换变成常人不懂的乱码,这样就可以通过公共的渠道传播信息,虽然谁都能收到你的乱码,但只有你和你的收信人能对乱码进行变换和反变换。 举个例子, 如果你把wang_luo_bang_piao (网络绑票) 这个短语加密成不可解密的乱码,可以用一串随机数,如319981309075395484….,作为密码钥匙来加密。方法非常简单,就是字母串对准密钥字符串,然后根据密钥的数字对字母在字母表上进行位移。如第一个字母w 对密钥第一位3,移三位,w,x,y,z,变成z。第二位字母a对 准密钥的第二位1,移一位变b。如此整个字母短语就变成了乱码 zbwphmxoibhsjiumis, 没有密码钥就不可分解的了。看到这儿您一定会说,既然加密用随机数就行了,这么简单,那为什么上面你还要讲一大通什么逆运算啦,质数啊什么的,直接用随机数位移加密不就行了吗? 红灯记的故事 可是这里还有个细节:您的随机数密钥必须要只给收信人,如果泄露给外人,你的密码就没秘密了。而利用数学硬难题的加密方法可以公开传送密钥。传送密钥的危险在样板戏里演过,就是红灯记里李玉和把密电码藏在粥底下的故事,需要抛头颅洒热血的。这个密电码就是一本写着一串串随机数的书,发信者和收信者每封电报用一页。只要随机数密电码不重复使用,从理论上讲这种加密手法是不可破解的。问题来了。战争中指挥部要和那么多战斗单位联系,如果用不重复的随机秘密本,实际操作有问题。一个折中的办法就是利用很长,很少重复的数字串来加密,密级低的通讯用重复较多的密钥,密级高的通讯用重复很少的密钥。可是这个问题带来的问题就是同一信息有可能出现在密级低和密级高的电报中。敌方从密级低的电报入手,破译后再攻密级高的。这种破译技术的一个传奇故事就是国军的密码破译家导致山本五十六的行程暴露,被美机埋伏击落。 密码机之迷 密码本传递的麻烦重复使用的问题使人研究更先进的技术,用机器产生重复程度低的密钥。于是就有人研究了机械计算机的方法。二次世界大战中德国的密码机“迷”(Enigma)就是这类机械计算机的典型. 1920年代德国工程师阿瑟 舍尔碧乌斯(Arthur Scherbius)开发 出一种机械的字母位移方法。原理非常简单,就是用一个轮子上有26个接点,把它们以一定方式俩俩连接起来,比如1和5,2和17,3和14….下图是他的专利附图,其左上角(Fig 2)就是这种连接的示意。 有了这样的连接,你输进第一个接点的电流就会从第五点流出,第二个接点的电流就移到 17位出…. 这样如果把26个接点对应26个字母,就成了一个机械的位移密码钥。可是一个轮子只能做一次位移,太容易被破解。如果再加几个轮子,破解难度就越来越高了。所以军用的Enigma有三个轮子。德国人脑子灵,让每个轮子通过电流两次,这样三个轮子就起到六个轮子的转换作用。下图就是这种机器的原理,有三个转换轮,加最左边一个“反射”轮,使输入码经过七次位移。 可以看到经过七次位移, A进去会出来一个G。而只要把右边轮子移一格,A进去就出来一个C。 所以根据每个轮子起始位置的不同,Enigma可以变换出非常很多的密码型式。军用的Enigma机器加上其他一些输入连接键盘,一共有 158,962,555,217,826,360,000 (1.5万亿亿 种)密 码变换型式,很接近用随机数加密 。 下 图 是 Enigma 的照片, 在实用的时候,先转动上面的三个齿轮设定好一种密码型式,比如图中的 ABY,还有反射盘的4,定为今天使用的密钥。这时在键盘上按一个键(如A),上面的灯盘上就会显示出一个加密后的字母,(如Y).另外每按一个键转换一个明码字符那三个轮子都会自动进一格, 明码的位移数就会再变一下。 如此你打进AAAAAAA….., 出来就是YCFQRTS…..。如果换另一个密码型式,如EIN, 按入AAAAA…出来就可能是BGYET…. 看起来几乎没有任何规律。德国人很自信地说,这种密码是不可破解的, “即使敌人获取了一台机器,它仍旧能够保证其加密系统的保密性。” 可是看起来没规律的事其实总有规律的。 看着像随机数,可实际还是差远了 。 1.5万亿亿种变换型式放进现代计算机,用不了多少功夫就破译了。令人尊敬的是破解Enigma之迷的时候还没有现代的数字计算机。完全是凭一些聪明的头脑。 [ 1 ]NPR 的节目在这里 http://thedianerehmshow.org/shows/2015-01-22/ransomware_the_latest_cybersecurity_threat_to_personal_computers_and_smartphones (待续,下篇先讲Enigma是怎么破译的,再讲讲怎么做计算机花几百年都不能破译的密码系统)
12191 次阅读|33 个评论
[转载][to be annotated] What is "e" on earth?
zhongzejiang 2013-9-6 00:50
This article is reprinted from an excellent website for learning mathematics intuitively-- betterexplained.com . Learn Right, Not Rote. An Intuitive Guide To Exponential Functions e e has always bothered me — not the letter, but the mathematical constant . What does it really mean? Math books and even my beloved Wikipedia describe e using obtuse jargon: The mathematical constant e is the base of the natural logarithm. And when you look up natural logarithm you get: The natural logarithm, formerly known as the hyperbolic logarithm, is the logarithm to the base e, where e is an irrational constant approximately equal to 2.718281828459. Nice circular reference there. It’s like a dictionary that defines labyrinthine with Byzantine: it’s correct but not helpful. What’s wrong with everyday words like “complicated”? I’m not picking on Wikipedia — many math explanations are dry and formal in their quest for “rigor”. But this doesn’t help beginners trying to get a handle on a subject (and we were all a beginner at one point). No more! Today I’m sharing my intuitive, high-level insights about what e is and why it rocks. Save your “rigorous” math book for another time. Here’s a quick video overview of the insights: (Unluckly this video is unavailable in mainland China...) e is NOT Just a Number Describing e as “a constant approximately 2.71828…” is like calling pi “an irrational number, approximately equal to 3.1415…”. Sure, it’s true, but you completely missed the point. Pi is the ratio between circumference and diameter shared by all circles . It is a fundamental ratio inherent in all circles and therefore impacts any calculation of circumference, area, volume, and surface area for circles, spheres, cylinders, and so on. Pi is important and shows all circles are related, not to mention the trigonometric functions derived from circles (sin, cos, tan). e is the base rate of growth shared by all continually growing processes. e lets you take a simple growth rate (where all change happens at the end of the year) and find the impact of compound, continuous growth , where every nanosecond (or faster) you are growing just a little bit. e shows up whenever systems grow exponentially and continuously: population, radioactive decay, interest calculations, and more. Even jagged systems that don’t grow smoothly can be approximated by e. Just like every number can be considered a “scaled” version of 1 (the base unit), every circle can be considered a “scaled” version of the unit circle (radius 1), and every rate of growth can be considered a “scaled” version of e (the “unit” rate of growth). So e is not an obscure, seemingly random number. e represents the idea that all continually growing systems are scaled versions of a common rate. Understanding Exponential Growth Let start by looking at a basic system that doubles after an amount of time. For example, Bacteria can split and “doubles” every 24 hours We get twice as many noodles when we fold them in half. Your money doubles every year if you get 100% return (lucky!) And it looks like this: Splitting in two or doubling is a very common progression. Sure, we can triple or quadruple, but doubling is convenient, so hang with me here . Mathematically, if we have x splits then we get 2^x times more “stuff” than when we started. With 1 split we have 2^1 or 2 times more. With 4 splits we have 2^4 = 16 times more. As a general formula: Said another way, doubling is 100% growth . We can rewrite our formula like this: It’s the same equation, but we separate “2″ into what it really is: the original value (1) plus 100%. Clever, eh? Of course, we can substitute any number (50%, 25%, 200%) for 100% and get the growth formula for that new rate. So the general formula for x periods of return is: This just means we use our rate of return, (1 + return), “x” times in a row. A Closer Look Our formula assumes growth happens in discrete steps. Our bacteria are waiting, waiting, and then boom , they double at the very last minute. Our interest earnings magically appear at the 1 year mark. Based on the formula above, growth is punctuated and happens instantly. The green dots suddenly appear. The world isn’t always like this. If we zoom in, we see that our bacterial friends split over time: Mr. Green doesn’t just show up: he slowly grows out of Mr. Blue. After 1 unit of time (24 hours in our case), Mr. Green is complete. He then becomes a mature blue cell and can create new green cells of his own. Does this information change our equation? Nope. In the bacteria case, the half-formed green cells still can’t do anything until they are fully grown and separated from their blue parents. The equation still holds. Money Changes Everything But money is different. As soon as we earn a penny of interest, that penny can start earning micro-pennies of its own. We don’t need to wait until we earn a complete dollar in interest — fresh money doesn’t need to mature. Based on our old formula , interest growth looks like this: But again, this isn’t quite right: all the interest appears on the last day. Let’s zoom in and split the year into two chunks. We earn 100% interest every year, or 50% every 6 months. So, we earn 50 cents the first 6 months and another 50 cents in the last half of the year: But this still isn’t right! Sure, our original dollar (Mr. Blue) earns a dollar over the course of a year. But after 6 months we had a 50-cent piece, ready to go, that we neglected! That 50 cents could have earned money on its own: Because our rate is 50% per half year, that 50 cents would have earned 25 cents (50% times 50 cents). At the end of 1 year we’d have Our original dollar (Mr. Blue) The dollar Mr. Blue made (Mr. Green) The 25 cents Mr. Green made (Mr. Red) Giving us a total of $2.25. We gained $1.25 from our initial dollar, even better than doubling! Let’s turn our return into a formula. The growth of two half-periods of 50% is: Diving into Compound Growth It’s time to step it up a notch. Instead of splitting growth into two periods of 50% increase, let’s split it into 3 segments of 33% growth. Who says we have to wait for 6 months before we start getting interest? Let’s get more granular in our counting. Charting our growth for 3 compounded periods gives a funny picture: Think of each color as “shoveling” money upwards towards the other colors (its children), at 33% per period: Month 0: We start with Mr. Blue at $1. Month 4: Mr. Blue has earned 1/3 dollar on himself, and creates Mr. Green, shoveling along 33 cents. Month 8: Mr. Blue earns another 33 cents and gives it to Mr. Green, bringing Mr. Green up to 66 cents. Mr. Green has actually earned 33% on his previous value, creating 11 cents (33% * 33 cents). This 11 cents becomes Mr. Red. Month 12: Things get a bit crazy. Mr. Blue earns another 33 cents and shovels it to Mr. Green, bringing Mr. Green to a full dollar. Mr. Green earns 33% return on his Month 8 value (66 cents), earning 22 cents. This 22 cents gets added to Mr. Red, who now totals 33 cents. And Mr. Red, who started at 11 cents, has earned 4 cents (33% * .11) on his own, creating Mr. Purple. Phew! The final value after 12 months is: 1 + 1 + .33 + .04 or about 2.37. Take some time to really understand what’s happening with this growth: Each color earns interest on itself and “hands it off” to another color. The newly-created money can earn money of its own, and on the cycle goes. I like to think of the original amount (Mr. Blue) as never changing. Mr. Blue shovels money to create Mr. Green, a steady 33 every 4 months since Mr. Blue does not change. In the diagram, Mr. Blue has a blue arrow showing how he feeds Mr. Green. Mr. Green just happens to create and feed Mr. Red (green arrow), but Mr. Blue isn’t aware of this. As Mr. Green grows over time (being constantly fed by Mr. Blue), he contributes more and more to Mr. Red. Between months 4-8 Mr. Green gives 11 cents to Mr. Red. Between months 8-12 Mr. Green gives 22 cents to Mr. Red, since Mr. Green was at 66 cents during Month 8. If we expanded the chart, Mr. Green would give 33 cents to Mr. Red, since Mr. Green reached a full dollar by Month 12. Make sense? It’s tough at first — I even confused myself a bit while putting the charts together. But see that each “dollar” creates little helpers, who in turn create helpers, and so on. We get a formula by using 3 periods in our growth equation: We earned $1.37, even better than the $1.25 we got last time! Can We Get Infinite Money? Why not take even shorter time periods? How about every month, day, hour, or even nanosecond? Will our returns skyrocket? Our return gets better, but only to a point. Try using different numbers of n in our magic formula to see our total return: n (1 + 1/n)^n------------------1 22 2.253 2.375 2.48810 2.5937100 2.70481,000 2.716910,000 2.71814100,000 2.7182681,000,000 2.7182804... The numbers get bigger and converge around 2.718. Hey… wait a minute… that looks like e! Yowza. In geeky math terms, e is defined to be that rate of growth if we continually compound 100% return on smaller and smaller time periods: This limit appears to converge, and there are proofs to that effect. But as you can see, as we take finer time periods the total return stays around 2.718. But what does it all mean? The number e (2.718…) is the maximum possible result when compounding 100% growth for one time period. Sure, you started out expecting to grow from 1 to 2 (that’s a 100% increase, right?). But with each tiny step forward you create a little “dividend” that starts growing on its own. When all is said and done, you end up with e (2.718…) at the end of 1 time period, not 2. e is the maximum, what happens when we compound 100% as much as possible. So, if we start with $1.00 and compound continuously at 100% return we get 1e. If we start with $2.00, we get 2e. If we start with $11.79, we get 11.79e. e is like a speed limit (like c, the speed of light) saying how fast you can possibly grow using a continuous process. You might not always reach the speed limit, but it’s a reference point: you can write every rate of growth in terms of this universal constant. (Aside: Be careful about separating the increase from the final result . 1 becoming e (2.718…) is an increase (growth rate) of 171.8%. e, by itself, is the final result you observe after all growth is taken into account (original + increase)). What about different rates? Good question. What if we grow at 50% annually, instead of 100%? Can we still use e? Let’s see. The rate of 50% compound growth would look like this: Hrm. What can we do here? Remember, 50% is the total return, and n is the number of periods to split the growth into for compounding. If we pick n=50, we can split our growth into 50 chunks of 1% interest: Sure, it’s not infinity, but it’s pretty granular. Now imagine we also divided our “regular” rate of 100% into chunks of 1%: Ah, something is emerging here. In our regular case, we have 100 cumulative changes of 1% each. In the 50% scenario, we have 50 cumulative changes of 1% each. What is the difference between the two numbers? Well, it’s just half the number of changes: This is pretty interesting. 50 / 100 = .5, which is the exponent we raise e to. This works in general: if we had a 300% growth rate, we could break it into 300 chunks of 1% growth. This would be triple the normal amount for a net rate of e^3. Even though growth can look like addition (+1%), we need to remember that it’s really a multiplication (x 1.01). This is why we use exponents (repeated multiplication) and square roots (e^1/2 means “half” the number of changes, i.e. half the number of multiplications). Although we picked 1%, we could have chosen any small unit of growth (.1%, .0001%, or even an infinitely small amount!). The key is that for any rate we pick, it’s just a new exponent on e: What about different times? Suppose we have 300% growth for 2 years. We’d multiply one year’s growth (e^3) by itself: And in general: Because of the magic of exponents, we can avoid having two powers and just multiply rate and time together in a single exponent. The big secret: e merges rate and time. This is wild! e^x can mean two things: x is the number of times we multiply a growth rate: 100% growth for 3 years is e^3 x is the growth rate itself: 300% growth for one year is e^3. Won’t this overlap confuse things? Will our formulas break and the world come to an end? It all works out. When we write: the variable x is a combination of rate and time. Let me explain. When dealing with continuous compound growth, 10 years of 3% growth has the same overall impact as 1 year of 30% growth (and no growth afterward). 10 years of 3% growth means 30 changes of 1%. These changes happen over 10 years, so you are growing continuously at 3% per year. 1 period of 30% growth means 30 changes of 1%, but happening in a single year. So you grow for 30% a year and stop. The same “30 changes of 1%” happen in each case. The faster your rate (30%) the less time you need to grow for the same effect (1 year). The slower your rate (3%) the longer you need to grow (10 years). But in both cases, the growth is e^.30 = 1.35 in the end. We’re impatient and prefer large, fast growth to slow, long growth but e shows they have the same net effect. So, our general formula becomes: If we have a return of r for t time periods, our net compound growth is e^rt. This even works for negative and fractional returns, by the way. Example Time! Examples make everything more fun. A quick note: We’re so used to formulas like 2^x and regular, compound interest that it’s easy to get confused (myself included). Read more about simple, compound and continuous growth . These examples focus on smooth, continuous growth , not the “jumpy” growth that happens at yearly intervals. There are ways to convert between them, but we’ll save that for another article. Example 1: Growing crystals Suppose I have 300kg of magic crystals. They’re magic because they grow throughout the day: I watch a single crystal, and in the course of 24 hours it sheds off its own weight in crystals. (The baby crystals start growing immediately at the same rate, but I can’t track that — I’m watching how much the original sheds). How much will I have after 10 days? Well, since the crystals start growing immediately, we want continuous growth . Our rate is 100% every 24 hours, so after 10 days we get: 300 * e^(1 * 10) = 6.6 million kg of our magic gem. This can be tricky: notice the difference between the input rate and the total output rate. The “input” rate is how much a single crystal changes: 100% in 24 hours. The net output rate is e (2.718x) because the baby crystals grow on their own. In this case we have the input rate (how fast one crystal grows) and want the total result after compounding (how fast the entire group grows because of the baby crystals). If we have the total growth rate and want the rate of a single crystal, we work backwards and use the natural log . Example 2: Maximum interest rates Suppose I have $120 in an account with 5% interest. My bank is generous and gives me the maximum possible compounding. How much will I have after 10 years? Our rate is 5%, and we’re lucky enough to compound continuously. After 10 years, we get $120 * e^(.05 * 10) = $197.85. Of course, most banks aren’t nice enough to give you the best possible rate. The difference between your actual return and the continuous one is how much they don’t like you. Example 3: Radioactive decay I have 10kg of a radioactive material, which appears to continuously decay at a rate of 100% per year. How much will I have after 3 years? Zip? Zero? Nothing? Think again. Decaying continuously at 100% per year is the trajectory we start off with. Yes, we do begin with 10kg and expect to “lose it all” by the end of the year, since we’re decaying at 10 kg/year. We go a few months and get to 5kg. Half a year left? Nope! Now we’re losing at a rate of 5kg/year, so we have another full year from this moment! We wait a few more months, and get to 2kg. And of course, now we’re decaying at a rate of 2kg/year, so we have a full year (from this moment). We get 1 kg, have a full year, get to .5 kg, have a full year — see the pattern? As time goes on, we lose material, but our rate of decay slows down. This constantly changing growth is the essence of continuous growth decay. After 3 years, we’ll have 10 * e^(-1 * 3) = .498 kg. We use a negative exponent for decay — we want a fraction (1/e rt ) vs a growth multiplier (e (rt) ). More Examples If you want fancier examples, try the Black-Scholes option formula (notice e used for exponential decay in value) or radioactive decay . The goal is to see e^rt in a formula and understand why it’s there: it’s modeling a type of growth or decay. And now you know why it’s “e”, and not pi or some other number: e raised to “r*t” gives you the growth impact of rate r and time t. There’s More To Learn! My goal was to: Explain why e is important: It’s a fundamental constant, like pi, that shows up in growth rates. Give an intuitive explanation: e lets you see the impact of any growth rate. Every new “piece” (Mr. Green, Mr. Red, etc.) helps add to the total growth. Show how it’s used: e^x lets you predict the impact of any growth rate and time period. Get you hungry for more: In the upcoming articles, I’ll dive into other properties of e. This article is just the start — cramming everything into a single page would tire you and me both. Dust yourself off, take a break and learn about e’s evil twin, the natural logarithm . Other Posts In This Series A Visual, Intuitive Guide to Imaginary Numbers Intuitive Arithmetic With Complex Numbers Understanding Why Complex Multiplication Works An Intuitive Guide To Exponential Functions e (This post) Demystifying the Natural Logarithm (ln) Understanding Exponents (Why does 0^0 = 1?) A Visual Guide to Simple, Compound and Continuous Interest Rates Using Logarithms in the Real World How To Measure Any Distance With The Pythagorean Theorem Surprising Uses of the Pythagorean Theorem Rescaling the Pythagorean Theorem Intuitive Guide to Angles, Degrees and Radians Intuitive Understanding Of Euler's Formula Intuitive Understanding of Sine Waves An Interactive Guide To The Fourier Transform
2151 次阅读|0 个评论
Principal soil functions
liminglei 2009-7-5 11:19
1.medium for plant growth; 2.foundation for building and civil structure; 3.raw material for industry; 4.sequestering carbon to mitigate climate change; 5.denaturing and filtering pollutants; 6.disposing of industrial and urban wastes; 7.being an archiv of human and planetary history; 8.being repository of germplasm and biodiversity; 9.maintaining and strengthing cycle of water and elements and moderating impacts of natural and anthropogenic perturbations on the environment; 10.maintaining aesthetic and cultural and artistic values of landscape and ecosystem and preserving cultural heritage.
个人分类: 生活点滴|2826 次阅读|0 个评论

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-6-4 11:41

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部