A long-winded X validated discussion on the [textbook] mean-variance conjugate posterior for the Normal model left me [mildly] depressed at the point and use of answering questions on this forum. Especially as it came at the same time as a catastrophic outcome for my mathematical statistics exam. Possibly an incentive to quit X validated as one quits smoking, although this is not the first attempt…
Archive for StackExchange
I’m getting the point
Posted in Statistics with tags Bayesian statistics, Bayesian textbook, conjugate priors, cross validated, final exam, StackExchange, teaching on February 14, 2019 by xi'angenerating from a failure rate function [X’ed]
Posted in Books, Kids, Statistics, University life with tags cross validated, failure rate, Monte Carlo Statistical Methods, probability theory, reliability, simulation, StackExchange, stackoverflow, survival analysis on July 4, 2015 by xi'anWhile I now try to abstain from participating to the Cross Validated forum, as it proves too much of a time-consuming activity with little added value (in the sense that answers are much too often treated as disposable napkins by users who cannot be bothered to open a textbook and who usually do not exhibit any long-term impact of the provided answer, while clogging the forum with so many questions that the individual entries seem to get so little traffic, when compared say with the stackoverflow forum, to the point of making the analogy with disposable wipes more appropriate!), I came across a truly interesting question the other night. Truly interesting for me in that I had never considered the issue before.
The question is essentially wondering at how to simulate from a distribution defined by its failure rate function, which is connected with the density f of the distribution by
From a purely probabilistic perspective, defining the distribution through f or through η is equivalent, as shown by the relation
but, from a simulation point of view, it may provide a different entry. Indeed, all that is needed is the ability to solve (in X) the equation
when U is a Uniform (0,1) variable. Which may help in that it does not require a derivation of f. Obviously, this also begs the question as to why would a distribution be defined by its failure rate function.
the Grumble distribution and an ODE
Posted in Books, Kids, R, Statistics, University life with tags cross validated, differential equation, forum, Gumble distribution, probability distribution, Runge-Kutta, StackExchange on December 3, 2014 by xi'anAs ‘Og’s readers may have noticed, I paid some recent visits to Cross Validated (although I find this too addictive to be sustainable on a long term basis!, and as already reported a few years ago frustrating at several levels from questions asked without any preliminary personal effort, to a lack of background material to understand hints towards the answer, to not even considering answers [once the homework due date was past?], &tc.). Anyway, some questions are nonetheless great puzzles, to with this one about the possible transformation of a random variable R with density
into a Gumble distribution. While the better answer is that it translates into a power law,
,
I thought using the S=R² transform could work but obtained a wrong sign in the pseudo-Gumble density
and then went into seeking another transform into a Gumbel rv T, which amounted to solve the differential equation
As I could not solve analytically the ODE, I programmed a simple Runge-Kutta numerical resolution as follows:
[sourcecode language=”r” gutter=”false”]
solvR=function(prec=10^3,maxz=1){
z=seq(1,maxz,le=prec)
t=rep(1,prec) #t(1)=1
for (i in 2:prec)
t[i]=t[i-1]+(z[i]-z[i-1])*exp(-z[i-1]+
exp(-z[i-1])+t[i-1]+exp(-t[i-1]))
zold=z
z=seq(.1/maxz,1,le=prec)
t=c(t[-prec],t)
for (i in (prec-1):1)
t[i]=t[i+1]+(z[i]-z[i+1])*exp(-z[i+1]+
exp(-z[i+1])+t[i+1]+exp(-t[i+1]))
return(cbind(c(z[-prec],zold),t))
}
[/sourcecode]
Which shows that [the increasing] t(w) quickly gets too large for the function to be depicted. But this is a fairly useless result in that a transform of the original variable and of its parameter into an arbitrary distribution is always possible, given that W above has a fixed distribution… Hence the pun on Gumble in the title.
some LaTeX tricks
Posted in Books, Kids, Statistics, University life with tags bigint, graphical extension, LaTeX, mathematical equations, StackExchange on November 21, 2014 by xi'anHere are a few LaTeX tricks I learned or rediscovered when working on several papers the past week:
- I am always forgetting how to make aligned equations with a single equation number, so I found this solution on the TeX forum of stackexchange, Namely use the equation environment and then an aligned environment inside. Or the split environment. But it does not always work…
- Another frustrating black hole is how to deal with integral signs that do not adapt to the integrand. Too bad we cannot use \left\int, really! Another stackexchange question led me to the bigints package. Not perfect though.
- Pierre Pudlo also showed me the commands \graphicspath{{dir1}{dir2}} and \DeclareGraphicsExtensions{.pdf,.png,.jpg} to avoid coding the entire path to each image and to put an order on the extension type, respectively. The second one is fairly handy when working on drafts. The first one does not seem to work with symbolic links, though…
unicode in LaTeX
Posted in Books, Linux, Statistics, University life with tags blogging, LaTeX, papers, StackExchange, Unicode, UTF-8, Wordpress on October 9, 2014 by xi'anAs I was hurriedly trying to cram several ‘Og posts into a conference paper (!), I looked around for a way of including Unicode characters straight away. And found this solution on StackExchange:
[sourcecode language=”lang” gutter=”false”]
\usepackage[mathletters]{ucs}
\usepackage[utf8x]{inputenc}
[/sourcecode]
which just suited me fine!