Hacker News new | past | comments | ask | show | jobs | submit login
Kalman and Bayesian Filters in Python (ipython.org)
215 points by cast42 on March 9, 2015 | hide | past | favorite | 28 comments



Author here.

I struggle a lot with the choice of medium. In many senses Jupyter (IPython Notebook) is fanstastic in terms of workflow. With latex+external program+external data+external output it is hard to keep everything in sync. Here, it all happens in one place. And, of course, it should make it easier for the reader. "What happens if I change this constant?" (A normal question with scientific processing). Trivial to find out in the notebook; much more painful with a paper book.

OTOH, latex is mature technology, and I mean that in in the most positive way possible. I don't have to worry that version 1.7 is coming out tomorrow, and that \int will no longer display an integral sign. I would like to make the book much more interactive - go all 'Bret Victor' on it, but at what cost? I just tried to use Plotly, for example, but they don't support the current version of matplotlib; they are skipping a version for whatever reason. I can't expect readers to play the version war just to read a book. Even with core Python+scipy stack I have doomed myself to endless maintenance as new, breaking changes occur. That is not hypothetical; IPython changed the format of the notebooks, and there went a weekend of work. And, with all of that said, I think most are just reading the PDF version, or using the static nbviewer rendering, not running it locally on their machine. Heck, that is how I read the other IPython books - in nbviewer or PDF form. You know what you can do in PDF that you can't do in Jupyter? Search. I can ctrl+f in a PDF and search an entire book; in Jupyter, which has no concept of a 'book', I have to go from notebook to notebook.

Anyway, I welcome ideas on how to approach this. I come from a world of C++ where code I wrote in 1995 is still running today, and still compiles with the latest compilers. I'm sure I'm not approaching this problem optimally due to lack of experience in web based mediums. But I do fear, not unreasonably, that once I move on the book will become essentially inaccessible in just 10-20 years or so.


A brief introduction stating what Kalman/Bayesian filters are and what they can be used for in the real world would be good for the start of the book.

In your Preface/Motivation section, you currently mention Kalman filters (4 times in the 1st 4 sentences) without explaining what it is and that seems to be the only intro to the topic.


Good point, I will do that.


Wasn't there a way to run the IPython notebook with a javascript kernel in the browser? At least that is how iocaml notebooks work (which AFAICT are IPython compatible): you have the full OCaml interpreter running as javascript and can edit any cells: http://gazagnaire.org/fuconf14/

This seems to be the Python equivalent: https://github.com/minrk/jskernel


Jupyter supports all kinds of kernels now. R, Julia, Javascript, Python, Haskell, Ruby, bash, it goes on and on. I am just giddy in love with the Jupyter project, despite the pain points about the current pace of changes.

http://jupyter.org/


Maybe you could set up a python virtualenv and use 'pip freeze' to dump the exact versions of all the libs you use. Then someone who wants to edit/render the notebook can 'pip install -r requirements.txt' to get an environment close to yours.

This still doesn't solve the problem that .ipynb format may not be stable, or that various python libs can introduce incompatibilities between versions but at least upgrading would be entirely under your control, and done at your pace.

Perhaps markdown with embedded code sections, or org-mode+org-babel would be a better long-term storage format, but I don't know if there are any tools that can round-trip to IPython notebooks, and you'd loose some of the interactivity.


I had no knowledge about pip freeze, I will look into that. I don't do Python professionally, except as a Matlab replacement.


If you want to do things in JavaScript and want to have your users avoid the version problem, the thing to do would be to provide an installer which pins versions of the various libraries (ostensibly through NPM) and/or to just distribute the package as a whole with the various libraries in place.

This can be automated. If you'd like, ping me at stonecypher at gmail dot com, and I'll share the system I use, and show you how to work with it.

Or you can just see it here: https://github.com/StoneCypher/flocks.rocks/blob/master/gulp...


Thanks for the offer. However, I kind of don't want to do things in Javascript, as Python is a fantastic platform for numeric computation, and so staying in that ecosystem makes a lot of sense (people can take my matplotlib code and go off and do their own plots for their filters, for example).

But I'm sort of at an inflection point. Is my book about using Python to do Kalman filtering, or is it about Kalman filtering, and it happens to use Python. So far it has largely been the latter, so I could see doing a Javascript version. But I think that puts my needs over the needs of the reader, which is probably wrong.


The ebook publishing world has a lot to learn from iPython notebooks. There's such resistance to javascript and active content in EPUB3, because somehow that's not a book. And to be fair, in most cases its stupid pet tricks. But this book is a great example of a real book that needs to be live.

Despite that, I think EPUB has a much better chance at evolving into something like ipynb than TeX or PDF.


I came here to say, as someone who's done a little work on kalman filters for robot localization, this seemed like a good introduction to what they are and what they mean. I would have loved to find this back in 2009 when I was finishing my bachelors! Thanks.


Sorry about the notebook format change. Did you loose work? Conversion should be handled for you, if not it is a bug, we can fix it on 3.1.

We would be happy to get more feedback on your writing process and your need, feel free to directly contact the team (IPython-dev at scipy.org, or issue on main IPython repo is fine).

As for concept of "book" or collection of notebook, we are working on that (integration with sphinx)


Have you tried conda, the package manager by continuum analytics? It stores pre compiled instances of packages for easy install cross platform and does some virtual env stuff.

Much easier and more robust than pip:

http://www.continuum.io/blog/conda


Sure, that is what I use. Great package. But I can't tell readers what to use.

I spent a bit of time supporting a reader. It is easy enough for me to get the versions, but the typical reader may not be au courant on the latest libraries in Python. For example, we have Python 3.4, and IPython 2.4. IPython 2.4 runs Python 3.4. That's confusing until you realize that the IPython version has nothing to do with the Python version.

I mean, none of this is unsurmountable, but it feels quite wrong to have to provide tech support to somebody that just wants to read a book.


Gotcha..

I wonder if this can help: http://nuitka.net/pages/overview.html?


I have just started, and will likely take a couple of days to finish, but I already like what I've read so far.

I really appreciate this author (Roger Labbe, yes?) as well as all the other authors of these online interactive ebooks or whatever they're called ("interabooks"?) for taking the time to prepare such comprehensive and informative material, purely to help others. Surely, preparing something like this could not have been easy or quick. The other day there was a fantastic one on digital signal processing, and today this.

Really, a big thanks to all you e-authors out there!


If you're one of those authors I too would like to thank you. Also I like to toot my own horn and help you. With some help I built ipy_pep8[1]. It helps iPython Notebook authors to make their code pep8 valid. It has already been used to improve "Probabilistic Programming and Bayesian Methods for Hackers".

[1]: https://github.com/bobjansen/ipy_pep8

[2]: http://nbviewer.ipython.org/github/CamDavidsonPilon/Probabil...


Sweet tool; I didn't know about it. I will be running it tonight against my source.


Cool! Please let me know what you think.


Sadly, I'm not one :(. But I do use iPython a lot, and will check out your tool. Thanks for the link!


It's a gteat way to contribute to existing projects ;)


Just got started on this over the weekend and was really impressed with not only the content but the presentation as well. Really enjoy learning through iPython notebooks (now Jupyter) and can only imagine things getting better in the future.


My Machine Learning professor uses iPython notebooks to teach the content in a format much like this. I think its a fantastic way to present it. You have working code snippets right next to theoretical LaTeX formulas and all of the text and matplotlib graphs to explain it.


I really like the subtle hat-tip to Star Wars with the use of TIE fighters in the graphs.

(see http://nbviewer.ipython.org/github/rlabbe/Kalman-and-Bayesia...)


I see error bars...I really don't think those were intended to be anything but error bars.


Total accident. Is it not clear to some that these are error bars?


Apparently there was some confusion, but from my perspective it was perfectly clear.


> I with IPython Notebook had spell check, but it doesn't seem to.

I got a chuckle out of this. :) PS, I love the presentation thus far.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: