tag:blogger.com,1999:blog-55502720375882941002024-02-06T22:35:28.050-08:00Rnaodm ThoughtsAtul Inglehttp://www.blogger.com/profile/07693026705299047212noreply@blogger.comBlogger30125tag:blogger.com,1999:blog-5550272037588294100.post-8195998694148060292019-03-01T08:30:00.001-08:002019-03-01T08:30:06.189-08:00Image Sensors World: SPAD Imagers at High Illumination<a href="https://image-sensors-world.blogspot.com/2019/03/spad-imagers-at-high-illumination.html?spref=bl">Image Sensors World: SPAD Imagers at High Illumination</a>: Arxiv.org publishes University of Wisconsin-Madison 27-page long paper " High Flux Passive Imaging with Single-Photon Sensors " by...Atul Inglehttp://www.blogger.com/profile/07693026705299047212noreply@blogger.com0tag:blogger.com,1999:blog-5550272037588294100.post-75247769048121377302016-01-15T09:45:00.000-08:002016-01-15T09:45:32.032-08:00Installing R packages for Rscript<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
Rscript usually fails if you try to load a package and the package is not installed. Merely adding a <span style="font-family: "Courier New",Courier,monospace;">install.packages</span> command at the top of your script doesn't make Rscript happy either because it doesn't know which CRAN mirror to get the packages from. Here's the right way to do it:<br />
<br />
<pre>
mirror.location <- "https://cran.mtu.edu"
library.path <- cat(.libPaths()) # this is the default installation path
get.necessary.packages <- function(){
if (library(package = "reshape", logical.return = TRUE, lib.loc=library.path) == FALSE){
install.packages("reshape", repos = mirror.location)
library("reshape", lib.loc = library.path)
}else{
library("reshape", lib.loc = library.path)
}
}
get.necessary.packages()
example <- matrix(data = c(1,1,1,1,2,2,2,2,3,3,3,3,1:12,1:12), ncol = 3)
example.melted <- melt(data = example)
example.casted <- cast(data = example.melted, formula = X2 ~ ., fun.aggregate = length)
cat('\n\n\n')
cat(example.casted[2,1])
cat('\n\n\n')
</pre>
<span style="font-family: "Courier New",Courier,monospace;"><br /><!-----><!-----><!-----><!-----><!-----><!-----></span>
<br />
<span style="font-family: "Courier New",Courier,monospace;"><span style="font-family: Times, "Times New Roman", serif;">Another way is to add the following line to your ~/.Rprofile file:</span></span><br />
<br />
</div>
<pre>
local({r <- getOption("repos")
r["CRAN"] <- "https://cran.mtu.edu"
options(repos=r)
})
</pre>
<span style="font-family: "Courier New",Courier,monospace;"><span style="font-family: Times, "Times New Roman", serif;">However this method may not be desirable if you are planning to distribute your code to laypeople who do not know what an Rprofile file is. <br>(Many thanks to RRR for helping me figure this out.) </span> </span></div>
Atul Inglehttp://www.blogger.com/profile/07693026705299047212noreply@blogger.com0tag:blogger.com,1999:blog-5550272037588294100.post-79120089078796978492015-01-11T19:19:00.002-08:002015-01-11T19:19:55.084-08:00novalidate-cert in Alpine mail on OS X<div dir="ltr" style="text-align: left;" trbidi="on">
Long story here: https://www.madboa.com/geek/pine-macosx/<br />
<br />
TLDR;<br />
<br />
1. In Keychain Access, select all certificates in System Roots and export it to a .pem file (say, cert.pem)<br />
2. Copy this file to /System/Library/OpenSSL/<br />
3. Restart alpine <br />
<br />
<br /></div>
Atul Inglehttp://www.blogger.com/profile/07693026705299047212noreply@blogger.com0tag:blogger.com,1999:blog-5550272037588294100.post-88884959110684883462014-05-12T08:40:00.001-07:002014-05-12T08:40:35.756-07:00From KD: 10 Point Agenda for the next Prime Minister of Ind...<a href="http://kiranydeshpande.blogspot.com/2014/05/10-point-agenda-for-next-prime-minister.html?spref=bl">From KD: 10 Point Agenda for the next Prime Minister of Ind...</a>: Honourable New Prime Minister of India, I am writing this a few days before you will take the oath of the office. You ...Atul Inglehttp://www.blogger.com/profile/07693026705299047212noreply@blogger.com0tag:blogger.com,1999:blog-5550272037588294100.post-89617198609074005802014-05-07T17:10:00.002-07:002014-05-07T17:10:26.554-07:00Michael Hirsch's Blog Post on Compiling Matlab code to run on any PC<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="hentry p1 post publish author-michael-hirsch category-matlab tag-mcr y2013 m08 d08 h13" id="post-647">
<div class="entry-title" style="text-align: left;">
Compiling Matlab code to run on any PC</div>
<div id="blog-title" style="color: white; text-align: left;">
<span><a href="http://blogs.bu.edu/mhirsch/" rel="home" title="Michael Hirsch">Michael Hirsch</a></span></div>
<h2 class="entry-title">
</h2>
<abbr class="published" title="2013-08-08T13:01:04-0400">August 8, 2013 at 13:01</abbr>
<div class="entry-content">
The Matlab Compiler allows you to compile your existing .m Matlab
script to run as an executable–e.g. on another PC that doesn’t have
Matlab installed. Typically you will compile for the same operating
system as you have on your Matlab PC (it might be possible to
cross-compile, but I have NOT checked this). You can also output code
suitable for compilation in another compiler–I’ll leave it to you to
read the mcc documentation for now.<br />
There are two caveats:<br />
1) You must have a Matlab Compiler license on the PC you’re using for Matlab–check this by typing in Matlab:<br />
<code>license('test','compiler')</code><br />
which must return a 1. If it’s 0, you don’t the Compiler license (you or your institution would have to buy a license)<br />
2) The computer where you intend to run the compiled program must have
the no-cost Matlab Compiler Runtime (MCR) installed–else you’ll get
errors like:<br />
<code>error while loading shared libraries: libmwlaunchermain.so: cannot open shared object file: No such file or directory</code><br />
Well, that’s the error I get in Linux.<br />
To install the Matlab Compiler Runtime (do this on your Matlab PC as
well as obviously the PC where you want to run the compiled Matlab code,
go to this website:<br />
<a href="http://www.mathworks.com/products/compiler/mcr/">http://www.mathworks.com/products/compiler/mcr/</a><br />
On Linux, just before finishing the installation you will be told to set environment variables <code>LD_LIBRARY_PATH</code> and <code>XAPPLRESDIR</code> with a long string of text. Here’s how to do that<br />
<ol>
<li>gedit matlabvariables</li>
<li>copy and paste the text into an export command like this:<br />
<code>## Matlab compiler Runtime (MCR)<br />
export
LD_LIBRARY_PATH=/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/sys/os/glnxa64:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/sys/java/jre/glnxa64/jre/lib/amd64/native_threads:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/sys/java/jre/glnxa64/jre/lib/amd64/server:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/sys/java/jre/glnxa64/jre/lib/amd64:$LD_LIBRARY_PATH
</code><code>export XAPPLRESDIR=/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/X11/app-defaults<br />
</code></li>
<li>chmod +x matlabvariables</li>
</ol>
Caution: The above .bashrc is only for Matlab R2013a on my PC, maybe
your PC is different–cut and paste the text from your installation
window.<br />
So before running your MCR program, first run ./matlabvariables,
which sets the appropriate variables when you need them on the PC you’re
running the MCR code on.<br />
Note: don’t just paste the export statements into .bashrc, because they
can interfere with other programs such as nmap–just use them when
needed.<br />
————-<br />
Now we write a test program by saving the following test into a file called MyMCC.m<br />
<code>function Y = MyMCC<br />
X = 0:0.01:2*3.14;<br />
Y = sin(X);<br />
plot(X,Y)<br />
title('Test of MCR')<br />
xlabel('x')<br />
ylabel('y')<br />
display('wow I ran an MCR program!')<br />
end<br />
</code><br />
Then type in Matlab console:<br />
<code>mcc -m -v -w enable -R -startmsg -R -completemsg MyMCC.m</code><br />
When that completes, open Terminal and in your MyMcc.m directory you’ll see an executable file MyMCC.<br />
Type in Terminal <code>./MyMCC</code> and you’ll see:<br />
<code><br />
./mcctest<br />
Initializing MATLAB Compiler Runtime version 8.1<br />
wow I ran an MCR program!<br />
</code><br />
along with a typical Matlab plot window showing a sine wave. Just close the plot window to end the execution of your program.<br />
Reference:<br />
<a href="http://blogs.mathworks.com/loren/2010/11/18/deploying-standalone-applications/">http://blogs.mathworks.com/loren/2010/11/18/deploying-standalone-applications/</a><br />
</div>
<div class="entry-meta">
<br />
</div>
</div>
</div>
Atul Inglehttp://www.blogger.com/profile/07693026705299047212noreply@blogger.com1tag:blogger.com,1999:blog-5550272037588294100.post-89587415998827795022014-04-21T12:07:00.000-07:002014-04-21T12:07:43.289-07:00Applied Mathematics<div dir="ltr" style="text-align: left;" trbidi="on">
"There is no branch of mathematics, however abstract, which may not some day be applied to phenomena of the real world."<br /><br />-Nikolai Lobachevsky </div>
Atul Inglehttp://www.blogger.com/profile/07693026705299047212noreply@blogger.com0tag:blogger.com,1999:blog-5550272037588294100.post-82440287011448302942014-01-09T22:09:00.002-08:002014-01-10T15:34:27.687-08:00wxBanker on Mac OS X 10.9.1<div dir="ltr" style="text-align: left;" trbidi="on">
It took a lot of trial and error getting wxBanker set up on the latest Mac OSX. Here's the sequence of steps that worked for me:<br />
<br />
1. Download the source from <a href="https://github.com/mrooney/wxbanker" target="_blank">github</a>.<br />
2. Download the dmg for wx<span style="font-family: inherit;">Python 2.8 from <a href="http://sourceforge.net/projects/wxpython/files/wxPython/2.8.11.0/wxPython2.8-osx-unicode-2.8.11.0-universal-py2.7.dmg/download">sourceforge.</a></span><br />
<span style="font-family: inherit;">3. Run the uninstaller script first to remove wxPython 2.9.*</span><br />
<span style="font-family: inherit;">4. Run the package installer for wxPython 2.8.</span><br />
<span style="font-family: inherit;">5. Run <span style="font-family: "Courier New",Courier,monospace;"></span></span><span style="font-family: inherit;"><span style="font-family: "Courier New",Courier,monospace;">arch -i386 python2.7 main.py</span></span><br />
<div>
</div>
<div>
<span style="font-family: inherit;">If you don't use the older version of wxPython, you will see an assertion failure in <span style="font-family: "Courier New",Courier,monospace;">DoInsert()</span> in the wxPython source.</span><span style="font-family: inherit;"> </span><br />
<span style="font-family: inherit;">If you don't run Python using arch it will default to the 64-bit version of Python, which wxPython2.8 doesn't like.</span><br />
<br />
<span style="font-family: inherit;">Finally, to s<span style="font-family: inherit;">ync your database using Dropbox, just remove any existing bank.db file and create a symlink: </span></span><br />
<span style="font-family: "Courier New",Courier,monospace;">ln -s ~/Dropbox/bank.db ~/.local/</span><wbr></wbr><span style="font-family: "Courier New",Courier,monospace;">share/wxbanker/</span><wbr></wbr><span style="font-family: "Courier New",Courier,monospace;">bank.db</span><br />
<br />
<span style="font-size: small;"><span style="font-family: inherit;">*A better way is to edit the source and use <span style="font-family: "Courier New",Courier,monospace;">wxversion</span> to select the older version of wxPython. That way it is not necessary to uinstall the newer version.</span></span><br />
<span style="font-size: x-small;"><span style="font-family: inherit;"><br /></span></span>
<span style="font-family: "Courier New",Courier,monospace;"><span style="font-family: inherit;"><span style="font-family: "Courier New",Courier,monospace;"><span style="font-family: inherit;"> </span></span> </span></span></div>
</div>
Atul Inglehttp://www.blogger.com/profile/07693026705299047212noreply@blogger.com0tag:blogger.com,1999:blog-5550272037588294100.post-87586876039458973322013-09-25T12:33:00.002-07:002013-09-25T12:33:58.154-07:00MATLAB startup.m<div dir="ltr" style="text-align: left;" trbidi="on">
Add these lines to your Matlab startup.m file for some amusement in life:<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">clc<br />s = RandStream('mt19937ar','Seed','shuffle');<br />RandStream.setGlobalStream(s);<br />disp('Why? Because...')<br />why</span><br />
<span style="font-family: "Courier New",Courier,monospace;">clear all</span></div>
Atul Inglehttp://www.blogger.com/profile/07693026705299047212noreply@blogger.com0tag:blogger.com,1999:blog-5550272037588294100.post-17477396987384221132013-05-15T19:05:00.000-07:002013-05-15T19:05:21.881-07:00Should I fill that survey?<div dir="ltr" style="text-align: left;" trbidi="on">
<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js" type="text/javascript">
MathJax.Hub.Config({
HTML: ["input/TeX","output/HTML-CSS"],
TeX: { extensions: ["AMSmath.js","AMSsymbols.js"],
equationNumbers: { autoNumber: "AMS" } },
extensions: ["tex2jax.js"],
jax: ["input/TeX","output/HTML-CSS"],
tex2jax: { inlineMath: [ ['$','$'], ["\\(","\\)"] ],
displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
processEscapes: true },
"HTML-CSS": { availableFonts: ["TeX"],
linebreaks: { automatic: true } }
});
</script>
I was one of "very few people" selected to complete a survey for some research study. In return for the time spent clicking radio buttons and checkboxes I was offered entry into a raffle: 2 prizes of \$150 each and 4 prizes of \$50 each. At first sight my reaction was: That's quite a reward!<br />
<br />
But, wait a minute: It looked like a really long and tedious survey to fill out, each page laid out in a 9 pt font, with over 10 pages of multiple-choice and open ended questions. It would easily take me 30 minutes from start to finish! Considering the work involved, I did not expect more than 100 people to complete the survey. Was it worth the effort? Let's check:<br />
<br />
$$<br />
E[\mbox{prize money}] = \frac{2}{100}\cdot 150 + \frac{4}{100}\cdot 50 = $5.<br />
$$<br />
<br />
*On average*, this deal looks like a $10/hr hourly job. I'll pass!</div>
Atul Inglehttp://www.blogger.com/profile/07693026705299047212noreply@blogger.com0tag:blogger.com,1999:blog-5550272037588294100.post-30111215925359999372013-03-20T10:09:00.002-07:002013-03-20T10:09:24.660-07:00Type I or Type II?<div dir="ltr" style="text-align: left;" trbidi="on">
The following table has helped me avoid confusing Type I and Type II errors. Write the true hypothesis numbers on the left, and the ones announced on top.<br />
<br />
<style type="text/css">TD P { margin-bottom: 0in; }P { margin-bottom: 0.08in; }</style>
<br />
<table cellpadding="4" cellspacing="0" style="width: 100%px;">
<colgroup><col width="85*"></col>
<col width="85*"></col>
<col width="85*"></col>
</colgroup><tbody>
<tr valign="TOP">
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: 1px solid #000000; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0.04in;" width="33%"><div align="CENTER">
<br /></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: 1px solid #000000; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0.04in;" width="33%"><div align="CENTER">
<b>Announced 0</b></div>
</td>
<td style="border: 1px solid #000000; padding: 0.04in;" width="33%"><div align="CENTER">
<b>Announced 1</b></div>
</td>
</tr>
<tr valign="TOP">
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="33%"><div align="RIGHT">
<b>Actually 0</b></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="33%"><div align="CENTER">
No error</div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0.04in; padding-top: 0in;" width="33%"><div align="CENTER">
Type I</div>
</td>
</tr>
<tr valign="TOP">
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="33%"><div align="RIGHT">
<b>Actually 1</b></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="33%"><div align="CENTER">
Type II</div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0.04in; padding-top: 0in;" width="33%"><div align="CENTER">
No error</div>
</td>
</tr>
</tbody></table>
<br />
Now read out the row and column headers as a binary number:<br />
<br />
<ul style="text-align: left;">
<li>01 (which is 1 in binary) means H0 was true and we announced H1. That is error Type I.</li>
</ul>
<br />
<ul style="text-align: left;">
<li>10 (which is 2 in binary) means H1 was true and we announced H0. That is error Type II.</li>
</ul>
<br />
(Or, perhaps, it is easier to remember that Type I is a false alarm and Type II is a miss.)<br />
<ul style="text-align: left;">
</ul>
</div>
Atul Inglehttp://www.blogger.com/profile/07693026705299047212noreply@blogger.com0tag:blogger.com,1999:blog-5550272037588294100.post-27159918798979798152013-03-03T14:47:00.000-08:002013-03-03T14:48:10.925-08:00Lost in Translation<div dir="ltr" style="text-align: left;" trbidi="on">
I recently came across a translation of a verse from Atharvaveda when browsing through a book on Hindusim by A. L. Herman [1]. Herman cites Maurice Bloomfield [2] as the source of this translation.<br />
<br />
<div style="text-align: center;">
<span style="font-size: small;"><i>As the best of the plants thou art reputed, O herb: turn this man for me to-day into a eunuch that wears his hair dressed!<br />
Turn him into a eunuch that wears his hair dressed, and into one
that wears a hood! Then Indra with a pair of stones shall break his
testicles both!<br /> O eunuch, into a eunuch thee I have turned; O
castrate, into a castrate thee I have turned; O weakling, into a
weakling thee I have turned! A hood upon his head, and a hair-net do we
place.<br /> The two canals, fashioned by the gods, in which man's
power rests, in thy testicles . . . . . . . . . . . . I break them with a
club.<br /> As women break reeds for a mattress with a stone, thus do I break thy member.</i></span></div>
<br />
There is no surprise that Herman refers to these verses as "grisly incantations" that were used against an enemy by specially requesting a priest who was aware of both the whereabouts of this magical herb and the exact procedure of casting this spell.<br />
<br />
A similar grisly translation, although with a slightly different interpretation can be found in the book by Griffith (which is freely available [3]):<br />
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
<span style="font-size: small;"><i>O Plant, thy fame is spread abroad as best of all the herbs that grow.<br /> Unman for me to-day this man that he may wear the horn of hair.<br /><span class="margnote"><span style="color: green;"><a href="http://www.blogger.com/blogger.g?blogID=5550272037588294100" name="an_0613802"></a></span></span> Make him a eunuch with a horn, set thou the crest upon his head.<br /> Let Indra with two pressing-stones deprive him of his manly strength.<br /><span class="margnote"><span style="color: green;"><a href="http://www.blogger.com/blogger.g?blogID=5550272037588294100" name="an_0613803"></a></span></span> I have unmanned thee, eunuch! yea, impotent! made thee impotent, and robbed thee, weakling! of thy strength.<br /> Upon his head we set the horn, we set the branching ornament.</i></span></div>
<br />
Griffith decodes this verse as being used by a woman to curse an unfaithful lover. <br />
<br />
A translation of the Atharvaveda to Hindi by the modern-day Hindu saint Shriram Sharma also follows this line of interpretation and roughly goes as follows (I am paraphrasing this from Hindi [4]):<br />
<br />
<div style="text-align: center;">
<i><span style="font-size: small;">O herb, you are the best of all herbs! Render my rival impotent, turn him into a eunuch. </span></i></div>
<div style="text-align: center;">
<i><span style="font-size: small;">O herb, turn our enemies into eunuchs. May Indra crumble their organ of manliness and cause the hair on their heads to grow long like a woman. </span></i></div>
<div style="text-align: center;">
<i><span style="font-size: small;">O enemy, through this ritual we have turned you into a eunuch, and dressed you up like a woman. We break the veins that go into your testicles. Just as women break weeds and reeds with a stone, we break the effect of your testicles.</span></i></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Finally, let us look at Dayananda Saraswati's interpretation of the same verse in his Hindi translation [5] which I paraphrase below:</div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
<i><span style="font-size: small;">O medicinal herb, you are supreme and renowned! Please turn this weakling into a useful man for me. </span></i></div>
<div style="text-align: center;">
<i><span style="font-size: small;">Turn the weakling into a useful man, make him active and hardworking.</span></i></div>
<div style="text-align: center;">
<i><span style="font-size: small;">And O powerful doctor! Break the illness in this man's testicles with two mighty rock-like weapons.</span></i></div>
<div style="text-align: center;">
<i><span style="font-size: small;">O debilitating illness, I have rendered you ineffective! I have rendered you powerless. We place </span></i><i><span style="font-size: small;">ornaments and </span></i><i><span style="font-size: small;">the strength to work on this man's forehead, who has been treated of his disease.</span></i></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
The first three translations seem to agree more or less, but this last one is a mysteriously distinct interpretation!</div>
<br />
<u>Appendix</u><br />
<br />
The original in Sanskrit is as follows.<br />
<br />
त्वं वीरुधां श्रेष्ठतमाभिश्रुतास्योषधे ।<br />
<div style="text-align: left;">
इमं मे अद्य पूरुषं क्लीबमोपशिनं कृधि ।।<br />
क्लीबं कृध्योपशिनमथो कुरीरिणं कृधि । </div>
<div style="text-align: left;">
अथास्येन्द्रो ग्रावभ्यामुभे भिनत्त्वाण्ड्यौ ।।<br />
क्लीबं क्लीबं त्वाकरं वध्रे वध्रिं त्वाकरमरसारसं त्वाकरम् । </div>
<div style="text-align: left;">
कुरीरमस्य शीर्षणि कुम्बं चाधिनिदध्मसि ।। <br />
ये ते नाड्यौ देवकृते ययोस्तिष्ठति वृष्ण्यम् । </div>
<div style="text-align: left;">
ते ते भिनद्मि शम्ययामुष्या अधि मुष्कयोः ।।<br />
यथा नडं कशिपुने स्त्रियो भिन्दन्त्यश्मना । </div>
<div style="text-align: left;">
एवा भिनद्मि ते शेपोSमुष्या अधि मुष्कयोः ।। </div>
<br />
<u>References</u><br />
<br />
[1] A. L. Herman, A Brief Introduction to Hindusim, Westview Press, 1991.<br />
[2] M. Bloomfield<span class="ista-content"><span class="c_e">, T<span class="c_b">ranslation of the Atharva-veda, </span></span></span><span class="ista-content"><span class="c_e">Sacred Books of the East, Vol. 42,</span></span><span class="ista-content"><span class="c_e"> </span></span><span class="ista-content"><span class="c_e"><span class="c_d">1897. Retrieved from <a href="http://www.sacred-texts.com/hin/sbe42/av131.htm">http://www.sacred-texts.com/hin/sbe42/av131.htm</a> </span></span></span><br />
<div style="text-align: left;">
<span class="ista-content"><span class="c_e"><span class="c_d">[3] Ralph T. H. Griffith, Hymns of </span></span></span>the Atharvaveda, 1895. Retrieved from <a href="http://www.sacred-texts.com/hin/av/av06138.htm">http://www.sacred-texts.com/hin/av/av06138.htm</a> </div>
<div style="text-align: left;">
[4] Shriram Sharma, Atharvaveda Samhita, Yuga Nirman Yojana, Mathura, India, 2005. Retrieved from <a href="http://literature.awgp.org/hindibook/vedPuranDarshan/atharvaved/athaveda1b.99">http://literature.awgp.org/hindibook/vedPuranDarshan/atharvaved/athaveda1b.99</a> </div>
<div style="text-align: left;">
[5] Dayanada Sarasvati, ``Atharvaveda Bhashabhashyam,'' c.a. 1975. Retrieved from <a href="http://www.aryasamajjamnagar.org/athrvaveda/atharvaveda.htm">http://www.aryasamajjamnagar.org/athrvaveda/atharvaveda.htm</a><br />
<br />
All links last accessed on August 18, 2012. </div>
</div>
Atul Inglehttp://www.blogger.com/profile/07693026705299047212noreply@blogger.com0tag:blogger.com,1999:blog-5550272037588294100.post-38024661928534767592013-02-23T15:13:00.001-08:002013-02-23T20:02:01.812-08:00The tale of intel reports and tail events<div dir="ltr" style="text-align: left;" trbidi="on">
<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js" type="text/javascript">
MathJax.Hub.Config({
HTML: ["input/TeX","output/HTML-CSS"],
TeX: { extensions: ["AMSmath.js","AMSsymbols.js"],
equationNumbers: { autoNumber: "AMS" } },
extensions: ["tex2jax.js"],
jax: ["input/TeX","output/HTML-CSS"],
tex2jax: { inlineMath: [ ['$','$'], ["\\(","\\)"] ],
displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
processEscapes: true },
"HTML-CSS": { availableFonts: ["TeX"],
linebreaks: { automatic: true } }
});
</script>
I remember posting something about bomb blasts on one occasion
expressing utter dismay at how people have become so insensitive to such
incidents. This is my second post on the same topic, this time with a
completely disinterested and technical disposition.<br />
<br />
Time and again we come across a news article claiming that the Center had warned the local or the state police about a possible terrorist attack. The recent Hyderabad blasts are no exception (see [1] for instance). The local government can take appropriate action based on such information provided by central intelligence teams. This time around the Chief minister decided not to take the information too seriously (``Andhra Pradesh Chief Minister Kiran Kumar Reddy had said those
were general alerts which often keep coming from the Centre'' [1]).<br />
<br />
I am not sure of the format in which such information is transmitted to the local ministers but let me hazard a few guesses: perhaps it is a lengthy report in teletype font typewritten on legal size eggshell finish papers, or maybe a frantic last minute phone call from PM Manmohan Singh saying something that is roughly equivalent to ``Take extra care dude.'' In any case, the minister (Mr. NKK Reddy, in the present case) probably makes up a numerical measure of the seriousness of the intel report.<br />
<br />
Let us suppose that a report comes in every day and Mr. Reddy decides to assign a random positive number as the ``alert level of the day.'' This procedure may be as simple as just counting the number of pages in the daily intel report. Now some notation: let $X_n$ denote the alert level for the day $n$. Assume $X_n$ is exponentially distributed with a (normalized) mean of $\lambda=1$. Mr. Reddy likes being conservative---he sees no point in putting the state on high alert just because one particular $X_n$ came out really big. After all, when one observes long sequences of random values, it is quite natural to expect some really huge readings, purely out of luck.<br />
<br />
Let $M_n = \max \{X_1, X_2, \cdots, X_n\}$ denote the largest of this sequence of i.i.d. exponentials. It is easy to derive the distribution $F_n(\cdot)$ of $M_n$ in terms of the common distribution $G(\cdot)$ of the i.i.d. exponential random variables:<br />
\begin{array}{rcl}<br />
F_n(t) &:=& Pr(M_n \leq t) \\<br />
&=& Pr(\max\{X_1,\cdots, X_n\} \leq t) \\<br />
&=& Pr(\bigcap_{i=1}^n \{X_i \leq t\}) \\<br />
&=& \prod_{i=1}^n Pr(X_i \leq t) \\<br />
&=& (G(t))^n \\<br />
&=& (1-\exp(-t))^n, <br />
\end{array}<br />
for $t\geq 0$.<br />
<br />
In order to be conservative and stay on budget, Mr. Reddy can raise an alarm only if the alert number he sees is in the $\alpha \%$ tail of the distribution of the maximum. Suppose $n=822$, which is how many days Mr. Reddy has been the CM [2]. $(100-\alpha) \%$ area under the density of $M_{822}$ can be calculated: $t_\alpha = F_{822}^{-1}(1-\alpha/100)$. If $\alpha = 5\%$, for example, then Mr. Reddy should pronounce high alert when he sees a number at least as big as 9.68197. See Figure below and also see [3].<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEIjGiQkMKJQ2_3fKDOIEb4PO6M2H4vSITP6xk2bwprSGCQlF0h7E_qYP_F5lj6hvbzWxhgy69oG7AVv2I3FYf09qNPExSOQOYg9OAQ1G_ouiadW4FLfuNeXlVl8zEOMNf9JrI6mUY3pcz/s1600/maxcdf.tiff" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="298" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEIjGiQkMKJQ2_3fKDOIEb4PO6M2H4vSITP6xk2bwprSGCQlF0h7E_qYP_F5lj6hvbzWxhgy69oG7AVv2I3FYf09qNPExSOQOYg9OAQ1G_ouiadW4FLfuNeXlVl8zEOMNf9JrI6mUY3pcz/s400/maxcdf.tiff" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figure: CDF of $M_n$ with location of 5% tail (click image for larger view)</td></tr>
</tbody></table>
<br />
<br />
I agree, this is an oversimplified (and probably useless) approach. But embellishments are possible. Foremost, the i.i.d. assumption may not be true. Some contextual information may be incorporated to create a mild correlation structure between the $X_n$'s. The other weakness in this model is that rare events like bomb blast may occur even when the alert level is quite low. (Remember what the great logodaedalist Mr. Chidambaram said in July 2011---the absence of intelligence is not failure of intelligence [4].)<br />
<br />
References<br />
<div id="pgurl">
[1] ``Specific alert was sent to Hyderabad Thursday morning: Centre'' in The Hindu, as reported by PTI available <a href="http://www.thehindu.com/news/national/specific-alert-was-sent-to-hyderabad-thursday-morning-centre/article4442733.ece?homepage=true" target="_blank">here</a>.<br />
[2] Wikipedia page on a list of Andhra Pradesh chief ministers is <a href="http://en.wikipedia.org/wiki/List_of_Chief_Ministers_of_Andhra_Pradesh#Chief_Ministers_of_Andhra_Pradesh" target="_blank">here</a>.<br />
[3] A calculation using Wolfram Alpha <a href="http://wolfr.am/WikLCX" target="_blank">here</a>.<br />
[4] ``No intel about blasts: Chidambaram,'' July 14, 2011. Available <a href="http://www.ndtv.com/article/india/no-intel-alerts-about-blasts-chidambaram-119146" target="_blank">here</a>. <br />
(Note: All links last accessed on Feb 23, 2013.)</div>
</div>
Atul Inglehttp://www.blogger.com/profile/07693026705299047212noreply@blogger.com0tag:blogger.com,1999:blog-5550272037588294100.post-10395800676496159422013-01-20T10:38:00.000-08:002014-02-19T15:51:21.053-08:00Lake Mendota Freeze Durations<div dir="ltr" style="text-align: left;" trbidi="on">
<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js" type="text/javascript">
MathJax.Hub.Config({
HTML: ["input/TeX","output/HTML-CSS"],
TeX: { extensions: ["AMSmath.js","AMSsymbols.js"],
equationNumbers: { autoNumber: "AMS" } },
extensions: ["tex2jax.js"],
jax: ["input/TeX","output/HTML-CSS"],
tex2jax: { inlineMath: [ ['$','$'], ["\\(","\\)"] ],
displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
processEscapes: true },
"HTML-CSS": { availableFonts: ["TeX"],
linebreaks: { automatic: true } }
});
</script>
<br />
<div dir="ltr" style="text-align: left;" trbidi="on">
<b>Q. Is the freeze duration of Lake Mendota decreasing over the years?</b><br />
<br />
Freeze duration data for Lake Mendota and other Madison lakes is available online. $N=156$ data points for Lake Mendota are available starting in the year 1855 [1]. Let us run a simple statistical test to check for a negative slope trend.<br />
<br />
Consider a linear model, i.e.,<br />
$$
y_n = \beta_1 n + \beta_0 + w_n,
$$ <br />
where $y_n$ denotes the freeze duration at any data point $0 \leq n \leq N-1$ and $w_n$ is i.i.d. Gaussian noise with zero mean and unknown variance. The regression coefficients $\hat{\beta_0}$ and $\hat{\beta_1}$ can be calculated from data using linear regression (see Figure below).<br />
<br />
Now, setting up the hypotheses:<br />
$$<br />
H_0: \beta_1 = 0<br />
$$<br />
and<br />
$$<br />
H_1: \beta_1 < 0.<br />
$$<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfLBq0dh6kdvEos8arABTinHcr3TQWbPxioUS0Srh2_E4qXZUK7NPmmOdY90Vyz1s0UTBz44LhTfJSH_lmdewNSceL40TNsQm2ouVnh3XW5rIR3ioVuTffFEeuWbNLoQZK597u-9qeo2Qj/s1600/freezedurplot.tiff" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfLBq0dh6kdvEos8arABTinHcr3TQWbPxioUS0Srh2_E4qXZUK7NPmmOdY90Vyz1s0UTBz44LhTfJSH_lmdewNSceL40TNsQm2ouVnh3XW5rIR3ioVuTffFEeuWbNLoQZK597u-9qeo2Qj/s400/freezedurplot.tiff" height="297" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figure: Linear fit to Lake Mendota freeze duration data</td></tr>
</tbody></table>
<br />
<br />
It is known that $$t = \frac{\hat{\beta_1}}{SE}$$ follows a t-distribution with $N-2$ degrees of freedom. Here $$SE = \sqrt{\frac{\frac{1}{N-2}\sum_{n=0}^{N-1} (y_n - \hat{\beta_1} n- \hat{\beta_0} )^2}{\;\;\;\;\;\;\;\sum_{n=0}^{N-1} \left(n-\frac{(N-1)(N-2)}{\;\;\;\;\;2N}\right)^2}}$$ is called the standard error [2].<br />
<br />
<b>A. Unless there is an algebra error in my calculations, the t-test shows that there is statistically significant negative slope trend in this data (at both 1% and 5% significance levels).</b><br />
<b><br /></b>
<b>References:</b><br />
[1] UW-Madison Department of Atmospheric and Oceanic Sciences. URL: http://www.aos.wisc.edu/~sco/lakes/Mendota-ice.html (Accessed: Jan 20, 2012)<br />
[2] T. Tarpey, Course Notes for Stat-630 at Wright State University. URL: http://www.wright.edu/~thaddeus.tarpey/stt630chap8.pdf (Accessed: Jan 20, 2012).<br />
<br />
<br />
<b>Appendix:</b><br />
I have copied data from [1] in a .csv file for easy access. You can download it <a href="https://uwmadison.box.com/MendotaFreezeDurationsCsv">here</a>. And here's some Octave code. Make sure the .csv file is in the same directory.<br />
<br />
<span style="font-family: "Courier New", Courier, monospace; font-size: small;">data = csvread('MendotaFreezeDurations.csv');<br />N = numel(data(:,1));<br />ply = polyfit(data(:,1), data(:,2), 1);<br />% ply = [-0.18829 117.82053]<br />SSE = sum((data(:,2)-polyval(ply, data(:,1))).^2);<br />% SSE = 4.6469e+04<br />MSE = SSE/(N-2);<br />SE = sqrt(MSE/sum( (data(:,1)-mean(data(:,1))).^2 ));<br />% SE = 0.030491<br />tstatistic = ply(1)/SE;<br />% tstatistic = -6.1754<br />tthresh1 = -tinv(0.99,N-2)<br />tthresh5 = -tinv(0.95,N-2)<br />if tstatistic < tthresh1, </span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: small;"> disp('H0 rejected at 1%'); </span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: small;">else, </span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: small;"> disp('H0 accepted at 1%'); </span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: small;">end;<br />if tstatistic < tthresh5, </span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: small;"> disp('H0 rejected at 5%'); </span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: small;">else, </span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: small;"> disp('H0 accepted at 5%'); </span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: small;">end;<br />% H0 is rejected in both cases. </span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: small;">% There is a statistically significant </span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: small;">% downward sloping trend.<br /> </span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: small;">plot(data(:,1), data(:,2),... </span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: small;"> data(:,1), polyval(ply, data(:,1)));<br />axis tight<br />ylabel('freeze duration (days)')<br />xlabel('data point')<br />title('lake Mendota freeze duration linear regression')<br />print -depsc freezedurplot.eps</span></span><br />
<span style="font-family: "Courier New", Courier, monospace;"><br /></span></div>
</div>
Atul Inglehttp://www.blogger.com/profile/07693026705299047212noreply@blogger.com0tag:blogger.com,1999:blog-5550272037588294100.post-52019200319179098382012-12-26T12:18:00.001-08:002012-12-26T16:52:29.740-08:00The land in Laṅkā is wooden<div dir="ltr" style="text-align: left;" trbidi="on">
Once Kaṡyapa's son Garuḍa expressed his desire to have a hearty meal to become strong enough to save his mother from the snakes. Kaṡyapa told Garuḍa about a huge elephant and a tortoise at the bottom of the ocean and told him to devour them. Garuḍa carried them onto a nearby Kalpavṛkṣa tree to enjoy his meal. But the weight of the well-built Garuḍa, together with the elephant, caused the tree branch to snap. Garuḍa held the branch with his beak stopping it from falling on the Vālakhilya (thumb-sized ṛṣis) who were meditating under the tree. Garuḍa then asked his father what he should do with the broken branch. Kaṡyapa directed him to take it some place far away. Laṅkā was established on this branch of that Kalpavṛkṣa tree, and therefore the land there is wooden.<br />
<br />
[1] Tales from the Kathasaritsagara, Arshia Sattar (translator), Penguin Classics, 1994.<br />
[2] The Ocean of Story, C. H. Tawney (translator), C. J. Sawyer Ltd., London, 1924.</div>
Atul Inglehttp://www.blogger.com/profile/07693026705299047212noreply@blogger.com1tag:blogger.com,1999:blog-5550272037588294100.post-63314634607429463852012-12-18T23:21:00.000-08:002012-12-18T23:24:00.558-08:00V for Vendetta [1]<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<b>V</b>:
[<i class="fine">Evey pulls out her mace</i>] I can assure you I mean you no harm.
<br />
<b>Evey Hammond</b>:
Who are you?
<br />
<b>V</b>:
Who? Who is but the form following the function of what and what I am is a man in a mask.
<br />
<b>Evey Hammond</b>:
Well I can see that.
<br />
<b>V</b>:
Of course you can. I'm not questioning your powers of observation; I'm
merely remarking upon the paradox of asking a masked man who he is.
<br />
<b>Evey Hammond</b>:
Oh. Right.
<br />
<b>V</b>:
But on this most auspicious of nights, permit me then, in lieu of the
more commonplace sobriquet, to suggest the character of this dramatis
persona.
<br />
<b>V</b>:
Voilà! In view, a humble vaudevillian veteran, cast vicariously as both
victim and villain by the vicissitudes of Fate. This visage, no mere
veneer of vanity, is a vestige of the vox populi, now vacant, vanished.
However, this valorous visitation of a by-gone vexation, stands vivified
and has vowed to vanquish these venal and virulent vermin vanguarding
vice and vouchsafing the violently vicious and voracious violation of
volition.
<br />
[<i class="fine">carves "V" into poster on wall</i>]
<br />
<b>V</b>:
The only verdict is vengeance; a vendetta, held as a votive, not in
vain, for the value and veracity of such shall one day vindicate the
vigilant and the virtuous.
<br />
<b>V</b>:
[<i class="fine">giggles</i>]
<br />
<b>V</b>:
Verily, this vichyssoise of verbiage veers most verbose, so let me
simply add that it's my very good honor to meet you and you may call me
V.
<br />
<b>Evey Hammond</b>:
Are you, like, a crazy person?
<br />
<b>V</b>:
I am quite sure they will say so. But to whom, might I ask, am I speaking with?
<br />
<b>Evey Hammond</b>:
I'm Evey.
<br />
<b>V</b>:
Evey? E-V. Of course you are.
<br />
<b>Evey Hammond</b>:
What does that mean?
<br />
<b>V</b>:
It means that I, like God, do not play with dice and do not believe in coincidence. Are you hurt?<br />
<br />
Reference:<br />
[1] IMDb http://www.imdb.com/title/tt0434409/quotes (Accessed Dec 19, 2012) </div>
Atul Inglehttp://www.blogger.com/profile/07693026705299047212noreply@blogger.com0tag:blogger.com,1999:blog-5550272037588294100.post-28685817479598719432012-11-23T12:16:00.001-08:002012-11-23T12:16:35.872-08:00Concatenation error<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: "Courier New",Courier,monospace;"><span style="font-family: Georgia,"Times New Roman",serif;">Any idea what is wrong here? </span></span><br />
<br />
<b><span style="font-family: "Courier New",Courier,monospace;">>> A = [-1./alpha.^2 -3./2./sig.^2, 1./alpha.^2-1./sig^2, -1./2./sig.^2;... </span></b><br />
<b><span style="font-family: "Courier New",Courier,monospace;">1./alpha.^2-1./sig.^2, -2./alpha.^2-1./sig.^2, 1./alpha.^2-1./2./sig.^2;... </span></b><br />
<b><span style="font-family: "Courier New",Courier,monospace;">-1./2./sig.^2, 1./alpha.^2-1./2./sig.^2, -1./alpha.^2-1./2./sig.^2];<br /><span style="color: red;">??? Error using ==> sym.cat>checkDimensions at 76<br />CAT arguments dimensions are not consistent.<br /><br />Error in ==> sym.cat>catMany at 39<br />[resz, ranges] = checkDimensions(sz,dim);<br /><br />Error in ==> sym.cat at 29<br /> y = catMany(dim, strs);<br /><br />Error in ==> sym.vertcat at 26<br /> y = cat(1,args{:});</span></span></b><br />
<br />
<span style="font-family: Georgia,"Times New Roman",serif;">Turns out there is an innocuous looking white space on the first line before the -3. Next time be careful when adding extra spaces to improve readability.</span></div>
Atul Inglehttp://www.blogger.com/profile/07693026705299047212noreply@blogger.com0tag:blogger.com,1999:blog-5550272037588294100.post-17961965594553317562012-09-19T14:39:00.003-07:002012-09-19T14:39:57.049-07:00Maps icon in iOS 6.0<div dir="ltr" style="text-align: left;" trbidi="on">
Interestingly, the maps icon in iOS 6.0 shows a route starting at BJ's Restaurant and Brewhouse on N DeAnza Blvd in Cupertino, CA. Or is it the Apple Company Store nearby? You'll never know.</div>
Atul Inglehttp://www.blogger.com/profile/07693026705299047212noreply@blogger.com0tag:blogger.com,1999:blog-5550272037588294100.post-51722213023800796562012-07-23T12:00:00.000-07:002013-02-25T12:00:38.127-08:00MathJax TeX Test Page<div dir="ltr" style="text-align: left;" trbidi="on">
<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>
<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript">
</script>
When $a \ne 0$, there are two solutions to \(ax^2 + bx + c = 0\) and they are
$$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$
Does that look ok?<br />
<br />
Yes. All I did was include this in my HTML code:<br />
<pre><code>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script >
<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript">
</script>
</code></pre>
</div>
Atul Inglehttp://www.blogger.com/profile/07693026705299047212noreply@blogger.com0tag:blogger.com,1999:blog-5550272037588294100.post-5439627172286552062012-07-21T23:45:00.000-07:002012-07-21T23:47:09.292-07:00A quick energy story in per capita numbers<div dir="ltr" style="text-align: left;" trbidi="on">
Here are some interesting numbers related to the energy sector that I obtained from WolframAlpha and the 2012 CO2 Report.<br />
<br />
1. Coal consumption<br />
USA 1.122 billion tonnes per year (2008)<br />
India 637.5 million tonnes per year (2008)<br />
<br />
2. Oil consumption<br />
USA 18.69 million barrels per day (2009) <br />
India 2.98 million barrels per day (2009)<br />
<br />
3. Greenhouse gases (CO2 equivalent) [1]<br />
USA 5500 million tonnes per year (2011)<br />
India 2000 million tonnes per year (2011)<br />
<br />
To make it more interesting, let us look at these numbers per person. (The population estimates used here are from 2010.)<br />
<br />
1. Coal consumption<br />
USA 3.63 tonnes per person per year<br />
India 0.525 tonnes per person per year<br />
<br />
2. Oil consumption<br />
USA 22.1 barrels per person per year<br />
India 0.896 barrels per person per year<br />
<br />
3. Greenhouse gases (CO2 equivalent)<br />
USA 17.8 tonnes per person per year<br />
India 1.65 tonnes per person per year<br />
<br />
And now, to make it sensational look at the ratios!<br />
<b><i>An average American uses 7 times more coal, 25 times more oil and produces 11 times more CO2 than an average Indian.</i></b><br />
<b><i><br /></i></b><br />
[1] Oliver JGJ, Janssens-Maenhout G and Peters JAHW (2012), "Trends in global CO2 emissions;" 2012 Report, The Hague: PBL Netherlands Environmental Assessment Agency; Ispra: Joint Research Centre. [Available online at <a href="http://edgar.jrc.ec.europa.eu/CO2REPORT2012.pdf">http://edgar.jrc.ec.europa.eu/CO2REPORT2012.pdf</a>. Last viewed July 22, 2012]</div>Atul Inglehttp://www.blogger.com/profile/07693026705299047212noreply@blogger.com0tag:blogger.com,1999:blog-5550272037588294100.post-18161559821690635152012-06-05T16:26:00.001-07:002012-06-05T16:26:21.174-07:00Mouseless Browsing Add-on<div dir="ltr" style="text-align: left;" trbidi="on">
Perhaps the only reason I will recommend installing this add-on is that it allows you to change scrolling shortcuts in Firefox to j and k. Additionally, I also assign the keys , and . for history backward and forward respectively. Under Preferences > Layout, make sure to hide all IDs and also uncheck the "Show tab ids" checkbox to get rid of all the annoying numbered IDs.</div>Atul Inglehttp://www.blogger.com/profile/07693026705299047212noreply@blogger.com0tag:blogger.com,1999:blog-5550272037588294100.post-48405866293177095652012-03-02T16:12:00.001-08:002012-03-02T16:18:06.275-08:00A law that no one can break (not even Apple)<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
The article ``A Law Apple Would Like to Break'' by James B. Stewart (appeared on-line on Feb 24, 2011 under `Common Sense') [1]<a href="http://www.blogger.com/blogger.g?blogID=5550272037588294100" name="one"></a> is fundamentally flawed in interpreting Bernoulli's law. The author uses Bernoulli's law to ``predict'' Apple's growth rate based on past numbers.<br />
<br />
Before pointing out the serious flaws in the Mr. Stewart's argument, let me formally state Bernoulli's law (also known as the weak law of large numbers) without getting into the mathematical nuances and notation: ``For an infinitely large collection of random numbers each generated independently and under identical conditions, the average converges to the true mean of the random variable [2]<a href="http://www.blogger.com/blogger.g?blogID=5550272037588294100" name="two"></a>.'' Armed with this (almost) precise statement it can be seen that the author's arguments are deficient on three counts.<br />
<br />
1. Although sales, revenue and such other economic indicators of a company's performance may be regarded as random variables, these numbers are neither independent, nor generated under identical conditions. It is easy to convince oneself that a company's performance numbers from the past and the present are correlated. Numbers in quarterly balance sheets are not generated by rolling a fair die over and over again!<br />
<br />
2. It is not clear what the true mean of the random variable that the author is referring to is. Hence, it is illogical to conclude that Apple's growth should slow down by using the ``revert-to-its-mean'' idea. We do not know what the true mean is (no matter how much analysts and experts speculate). I do agree that there are other physical limitations that may lead to slower growth in case of larger companies (of course Apple can not sell an iPhone to every human and rock on this planet), but attributing it to the weak law is absurd.<br />
<br />
3. Finally, Bernoulli's law applies to random numbers when the collection grows infinitely large. It says nothing about individual outcomes. Incidentally, colloquial misuse of Bernoulli's law (as in the present article) is so common that it has a name of its own -- the Gambler's fallacy [3]<a href="http://www.blogger.com/blogger.g?blogID=5550272037588294100" name="three"></a>. A streak of ten consecutive heads in ten tosses of a fair coin does not increase the possibility of seeing tails in subsequent tosses! It is natural and quite intuitive to think that the coin toss experiment should eventually ``even out.'' In fact, one can justifiably invoke the weak law of large numbers and say that if a fair coin is tossed infinitely many times, then the fraction heads (and tails) will become arbitrarily close to 1/2. However, twisting this argument and saying that a streak of one hundred consecutive heads raises the chances of seeing tails in the 101<sup>st</sup> toss is naive.<br />
<br />
To conclude, I agree with the author's intuition that Apple's growth may slow down, but I have serious reservations about ascribing this to Bernoulli's law of large numbers. Apple is not running against this law in any manner whatsoever. No one can.<br />
<br />
<a href="http://www.blogger.com/blogger.g?blogID=5550272037588294100" name="notes"></a>Notes:<br />
[1] See the news article at <a href="http://nyti.ms/zLyT4E" target="_blank">NYT.com.</a><br />
[2] For those with a penchant for mathematics, a precise statement of the weak law can be found in any standard book on probability. For instance, see J. A. Gubner, <i>Probability and Random Processes for Electrical and Computer Engineers</i>. Cambridge University Press, 2006, pp. 576.<br />
[3] The term originates from an interesting story that can be found on <a href="http://www.fallacyfiles.org/gamblers.html" target="_blank">fallacyfiles.org.</a> Also see the <a href="http://en.wikipedia.org/wiki/Gamblers_fallacy">Wikipedia page</a> on this topic and about the rampant misuse of Bernoulli's law under the garb of the <a href="http://en.wikipedia.org/wiki/Law_of_averages">law of averages</a>.</div>
</div>Atul Inglehttp://www.blogger.com/profile/07693026705299047212noreply@blogger.com0Madison, WI, USA43.0730517 -89.401230242.9802592 -89.5591587 43.1658442 -89.2433017tag:blogger.com,1999:blog-5550272037588294100.post-46340298697990694642012-02-19T17:16:00.000-08:002012-02-19T17:33:51.419-08:00Confusing lim sup and lim infThe definitions of <a href="http://www.codecogs.com/eqnedit.php?latex=%5Climsup" target="_blank"><img src="http://latex.codecogs.com/gif.latex?%5Climsup" title="\limsup" /></a> and <a href="http://www.codecogs.com/eqnedit.php?latex=%5Climinf" target="_blank"><img src="http://latex.codecogs.com/gif.latex?%5Climinf" title="\liminf" /></a> can get super confusing. I h0pe typing it out will help me remember it once and for all.<br /><br />Let <a href="http://www.codecogs.com/eqnedit.php?latex=%5C%7Bx_n%5C%7D" target="_blank"><img src="http://latex.codecogs.com/gif.latex?%5C%7Bx_n%5C%7D" title="\{x_n\}" /></a> be a sequence of real numbers indexed by <a href="http://www.codecogs.com/eqnedit.php?latex=n%20%5Cin%20%5Cmathbf%7BN%7D" target="_blank"><img src="http://latex.codecogs.com/gif.latex?n%20%5Cin%20%5Cmathbf%7BN%7D" title="n \in \mathbf{N}" /></a>. Consider the sequence <a href="http://www.codecogs.com/eqnedit.php?latex=y_k%20=%20%5Csup_%7Bn%20%5Cgeq%20k%7D%20x_n" target="_blank"><img src="http://latex.codecogs.com/gif.latex?y_k%20=%20%5Csup_%7Bn%20%5Cgeq%20k%7D%20x_n" title="y_k = \sup_{n \geq k} x_n" /></a> which is formed using the supremums of tails of the original sequence. Observe that <a href="http://www.codecogs.com/eqnedit.php?latex=y_k" target="_blank"><img src="http://latex.codecogs.com/gif.latex?y_k" title="y_k" /></a> is non-increasing (since ``the supremum over a smaller set can only get smaller''). We define<a href="http://www.codecogs.com/eqnedit.php?latex=%5Climsup%20x_n%20:=%20%5Cinf_k%20y_k%20=%20%5Cinf_k%20%5Csup_%7Bn%5Cgeq%20k%7D%20x_n" target="_blank"><img src="http://latex.codecogs.com/gif.latex?%5Climsup%20x_n%20:=%20%5Cinf_k%20y_k%20=%20%5Cinf_k%20%5Csup_%7Bn%5Cgeq%20k%7D%20x_n" title="\limsup x_n := \inf_k y_k = \inf_k \sup_{n\geq k} x_n" /></a>.<br /><br />Now if we switch the order of infimum and supremum in the above definition, the new quantity still makes sense (because the sequence of infimums of tails is non-decreasing). It is natural to define <a href="http://www.codecogs.com/eqnedit.php?latex=%5Climinf%20x_n%20:=%20%5Csup_k%20%5Cinf_%7Bn%5Cgeq%20k%7D%20x_n" target="_blank"><img src="http://latex.codecogs.com/gif.latex?%5Climinf%20x_n%20:=%20%5Csup_k%20%5Cinf_%7Bn%5Cgeq%20k%7D%20x_n" title="\liminf x_n := \sup_k \inf_{n\geq k} x_n" /></a>.<br /><br />When faced with <a href="http://www.codecogs.com/eqnedit.php?latex=%5Climsup" target="_blank"><img src="http://latex.codecogs.com/gif.latex?%5Climsup" title="\limsup" /></a>, think of a sequence of supremums obtained by sequentially chopping off the initial terms of the given sequence. Then take its limit, i.e., its infimum. One can interpret <a href="http://www.codecogs.com/eqnedit.php?latex=%5Climinf" target="_blank"><img src="http://latex.codecogs.com/gif.latex?%5Climinf" title="\liminf" /></a> in a similar way.Atul Inglehttp://www.blogger.com/profile/07693026705299047212noreply@blogger.com0tag:blogger.com,1999:blog-5550272037588294100.post-8437182989455313182012-02-06T15:02:00.000-08:002012-02-06T15:09:42.382-08:00*Must* use parfor!I was recently implementing a Monte Carlo simulation with 50000 particles for estimating a probability density function in <a href="http://www.codecogs.com/eqnedit.php?latex=$%5Cmathbf%7BR%7D%5E2$" target="_blank"><img src="http://latex.codecogs.com/gif.latex?$%5Cmathbf%7BR%7D%5E2$" title="$\mathbf{R}^2$" /></a> which took me 1100 seconds of runtime. Using Matlab's profiling tool, I found that 99% of the time was being spent on generating the new set of 50000 sample points from the old sample points. I immediately switched to a parallel looping strategy with 8 workers in parallel. The new runtime dropped to 80 seconds. Next, I found that I was calling a ``coinflip'' function in every loop. I removed it from the loop and instead stored a sequence of coinflips in memory using Matlab's binornd function and simply accessed this vector of ``already flipped coins'' in the parfor. The final runtime was 40 seconds.Atul Inglehttp://www.blogger.com/profile/07693026705299047212noreply@blogger.com0tag:blogger.com,1999:blog-5550272037588294100.post-19261949307664098262012-01-28T17:05:00.000-08:002012-01-28T17:35:06.437-08:00"So, what are you working on?"I have been asked about my PhD research on multiple occasions. The following description keeps people from yawning and/or dozing off while I ramble about what I work on these days.<br /><br /><div style="text-align: left;"><span style="color: rgb(153, 153, 153);">Imagine that you are running a 100 meter sprint. Once in a while, you are nudged by a mischievous member of the audience causing you to speed up or slow down instantaneously (depending on whether the mischievous individual pushed you from behind or the front, respectively). You continue to run at a constant speed between nudges.</span><br style="color: rgb(153, 153, 153);"><br style="color: rgb(153, 153, 153);"><span style="color: rgb(153, 153, 153);">Now, also imagine that there are sensors and timers at every meter mark along the track that log the time you cross each sensor. But these timers are inaccurate; so they record some number that may be slightly bigger or smaller than the actual time you crossed the sensor.</span><br style="color: rgb(153, 153, 153);"><br style="color: rgb(153, 153, 153);"><span style="color: rgb(153, 153, 153);">Given these 100 timer readings, can you find the locations where you were nudged by the frolicsome bystander?</span><br /></div>Atul Inglehttp://www.blogger.com/profile/07693026705299047212noreply@blogger.com0tag:blogger.com,1999:blog-5550272037588294100.post-77696323457833841402012-01-21T12:12:00.000-08:002012-01-21T13:04:23.387-08:00Prior, posterior, likelihood, MAP, MLLet <a href="http://www.codecogs.com/eqnedit.php?latex=%5Ctheta" target="_blank"><img src="http://latex.codecogs.com/gif.latex?%5Ctheta" title="\theta" /></a> be a parameter and <a href="http://www.codecogs.com/eqnedit.php?latex=X" target="_blank"><img src="http://latex.codecogs.com/gif.latex?X" title="X" /></a> be the observation or data.<br /><p style="margin: 0px; text-indent: 0px;"><br /></p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">The <span style="font-weight: bold;">posterior density</span> is the probability density of <a href="http://www.codecogs.com/eqnedit.php?latex=%5Ctheta" target="_blank"><img src="http://latex.codecogs.com/gif.latex?%5Ctheta" title="\theta" /></a> given the observation, that is, <a href="http://www.codecogs.com/eqnedit.php?latex=$p%28%5Ctheta%20%7C%20X%29$" target="_blank"><img src="http://latex.codecogs.com/gif.latex?$p%28%5Ctheta%20%7C%20X%29$" title="$p(\theta | X)$" /></a>. </p> <p style="margin: 0px; text-indent: 0px;"><br /></p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">The <span style="font-weight: bold;">a priori (or prior) density</span> is the probability density of <a href="http://www.codecogs.com/eqnedit.php?latex=%5Ctheta" target="_blank"><img src="http://latex.codecogs.com/gif.latex?%5Ctheta" title="\theta" /></a> before any observations are made, that is, <a href="http://www.codecogs.com/eqnedit.php?latex=p%28%5Ctheta%29" target="_blank"><img src="http://latex.codecogs.com/gif.latex?p%28%5Ctheta%29" title="p(\theta)" /></a>.</p> <p style="margin: 0px; text-indent: 0px;"><br /></p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">The <span style="font-weight: bold;">likelihood density</span> is the probability of observed data, given the model parameters, that is, <a href="http://www.codecogs.com/eqnedit.php?latex=p%28X%20%7C%20%5Ctheta%29" target="_blank"><img src="http://latex.codecogs.com/gif.latex?p%28X%20%7C%20%5Ctheta%29" title="p(X | \theta)" /></a>.</p> <p style="margin: 0px; text-indent: 0px;"><br /></p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">Using Bayes' rule, it is easy to see that</p> <p style="margin: 0px; text-indent: 0px;"><br /></p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:2;"><a href="http://www.codecogs.com/eqnedit.php?latex=p%28%5Ctheta%20%7C%20X%29%20%5Cpropto%20p%28%5Ctheta%29%20p%28X%20%7C%20%5Ctheta%29" target="_blank"><img src="http://latex.codecogs.com/gif.latex?p%28%5Ctheta%20%7C%20X%29%20%5Cpropto%20p%28%5Ctheta%29%20p%28X%20%7C%20%5Ctheta%29" title="p(\theta | X) \propto p(\theta) p(X | \theta)" /></a><br /></p> <p style="margin: 0px; text-indent: 0px;"><br /></p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">or, posterior <a href="http://www.codecogs.com/eqnedit.php?latex=%5Cpropto" target="_blank"><img src="http://latex.codecogs.com/gif.latex?%5Cpropto" title="\propto" /></a> prior <a href="http://www.codecogs.com/eqnedit.php?latex=%5Ctimes" target="_blank"><img src="http://latex.codecogs.com/gif.latex?%5Ctimes" title="\times" /></a> likelihood.</p> <p style="margin: 0px; text-indent: 0px;"><br /></p><p style="margin: 0px; text-indent: 0px;">When learning an unknown parameter from data, two commonly used estimation methods are as follows.<span style="font-weight: bold;"><br /></span></p><p style="margin: 0px; text-indent: 0px;"><span style="font-weight: bold;"><br /></span></p><p style="margin: 0px; text-indent: 0px;"><span>1.</span><span style="font-weight: bold;"> Maximum a posteriori</span> (MAP) estimate</p><p style="margin: 0px; text-indent: 0px;"><br /></p><p style="margin: 0px; text-indent: 0px;"> <a href="http://www.codecogs.com/eqnedit.php?latex=%5Ctheta_%7BMAP%7D%20=%20%5Carg%20%5Cmax_%20%5Ctheta%20p%28%5Ctheta%20%7C%20X%29" target="_blank"><img src="http://latex.codecogs.com/gif.latex?%5Ctheta_%7BMAP%7D%20=%20%5Carg%20%5Cmax_%20%5Ctheta%20p%28%5Ctheta%20%7C%20X%29" title="\theta_{MAP} = \arg \max_ \theta p(\theta | X)" /></a> <span style="font-weight: bold;"><br /></span></p><p style="margin: 0px; text-indent: 0px;"><span style="font-weight: bold;"><br /></span></p><p style="margin: 0px; text-indent: 0px;"><span>2.</span><span style="font-weight: bold;"> Maximum likelihood</span> (ML) estimate</p><p style="margin: 0px; text-indent: 0px;"><br /></p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"> <a href="http://www.codecogs.com/eqnedit.php?latex=%5Ctheta_%7BML%7D%20=%20%5Carg%20%5Cmax%20_%5Ctheta%20p%28X%20%7C%20%5Ctheta%29" target="_blank"><img src="http://latex.codecogs.com/gif.latex?%5Ctheta_%7BML%7D%20=%20%5Carg%20%5Cmax%20_%5Ctheta%20p%28X%20%7C%20%5Ctheta%29" title="\theta_{ML} = \arg \max _\theta p(X | \theta)" /></a></p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br /></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">Notice that under a uniform prior, MAP and ML are identical.</p>Atul Inglehttp://www.blogger.com/profile/07693026705299047212noreply@blogger.com0