Thursday, May 15, 2014

Linear regression with errors in X and Y with Python: BCES

I finally had the chance to upload my BCES linear regression python code to Github!

If you need to do linear regression with measurement errors in X and Y, including intrinsic scatter, please check it out. Even better, if you have suggestions to improve or speed up the code, please contribute by all means!

Wednesday, January 29, 2014

LaTeX tricks

Here is a collection of useful latex tricks I have been using in my papers.

How to add "sticky note" annotations to your manuscript

In the preamble of the document, add
\usepackage{todonotes}


For sticky notes:
\todo{your sticky note comment}



For notes placed in the text:
\todo[inline]{your sticky note comment}


For a missing figure box, such that you want to remind yourself to add a plot there later:
\missingfigure{figure description}


Read this for more options and the documentation of the todonotes package.


How to highlight or cross-out text

In the preamble of the document, add
\usepackage{color, soul}
\setstcolor{red}


For highlighted text:
\hl{your highlighted text}


For crossing-out text:


Check this out for more options.



For commenting out larger chunks of text

In the preamble of the document, add
\usepackage{verbatim}


Then put the text you want to comment out inside the environment:
\begin{comment}
everything your want to not show up in the document
\end{comment}

Can be way more powerful and faster than appending the % character to the beginning of each line.


Thursday, January 16, 2014

Video tutorial: Bayesian data analysis with PyMC 3

I highly recommend the tutorial by Thomas Wiecki on using PyMC 3 to perform Bayesian data analysis. Some of the cool things he demonstrates in this ~50 min video:

  • summary of Bayesian analysis and Bayesian theorem
  • application for parameter estimation for a few introductory examples: coin-flipping experiment, simple linear regression
  • new features of PyMC 3 with respect to v2
  • how to construct a model in PyMC 3 and a few notes on samplers
  • more advanced example: application to time series of correlated stocks, then linear regression of correlated stocks with a time-dependent slope (!!)

Monday, December 16, 2013

Interactive plots in ipython notebooks

A couple of ways of doing interactive plots and animations in an ipython notebook:

I am sure there are many other ways, and if you know of nice ways please post in the comments. 

Thursday, September 12, 2013

Monday, September 9, 2013

Easily run fortran code from an IPython notebook cell

I just learned a potentially very useful trick for people running fortran code. By following the instructions on this link, you can copy and paste fortran code to an IPython notebook cell and then use a ipython magic command to run it on-the-fly. I haven't had time to test it yet, so if you have success with it, please let me know. Kudos to @fperez_org.

On a separate note, IPython 1.1 is out!

Update (Sep. 23rd 2013): Here is a tutorial on how to use the fortran IPython magic.