example calls of information-theory functions?

68 views
Skip to first unread message

Lee Spector

unread,
May 16, 2013, 8:57:49 AM5/16/13
to inca...@googlegroups.com

I'd like to use some of the functions in http://liebke.github.io/incanter/branch-1.0.x/information-theory-api.html (mainly mutual-information), but I'm not completely clear about what the arguments should look like.

Does anyone have any example code that calls these, preferably for a simple example?

Thanks,

-Lee


--
Lee Spector, Professor of Computer Science
Cognitive Science, Hampshire College
893 West Street, Amherst, MA 01002-3359
lspe...@hampshire.edu, http://hampshire.edu/lspector/
Phone: 413-559-5352, Fax: 413-559-5438

David Edgar Liebke

unread,
May 16, 2013, 9:34:39 AM5/16/13
to inca...@googlegroups.com
Hi Lee,

The information-theory namespace was pulled out a while back and became part of the Infer library, http://github.com/aria42/infer.

But to your question, it appears, based on the source code, that the mutual information function takes a nested map of categories to counts, representing a joint distribution and a vector of two maps each representing the individual distributions.

(def X {:a 2, :b 1, :c 4, :d 3})
(def Y {:a 1 :b 4, :c 1, :d 2})

(def XY {:a {:a 0, :b 1, :1, :d 5}, :b {:a 4, :b 1, :c 1, :d 1}, :c {...}, :d {...}}) ;; top-level keys represent the X value.

(mutual-information XY [X Y])

I haven't actually tried it, but hopefully that will be enough to get you started.

David
> --
>
> ---
> You received this message because you are subscribed to the Google Groups "Incanter" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to incanter+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Lee Spector

unread,
May 17, 2013, 10:27:23 AM5/17/13
to inca...@googlegroups.com

Thanks David.

I found looking at the tests in infer's information_theory_test.clj to be useful as well.

Unfortunately, when I try to use infer.information-theory I get errors, starting with:

Exception in thread "main" java.lang.IllegalStateException: Can't dynamically bind non-dynamic var: clojure.contrib.macro-utils/protected-symbols, compiling:(clojure/contrib/monads.clj:195)

This is after adding [infer "1.0-SNAPSHOT"] to the project.clj and doing lein deps, which seems to work. It's in a new clojure 1.4.0 project.

Any ideas?

Thanks,

-Lee

liebke

unread,
May 17, 2013, 10:49:34 AM5/17/13
to Incanter
Sorry, no idea. Infer hasn't been updated in a few years and is based
on a really old version of Clojure (1.2.0-master-SNAPSHOT) as well as
the old clojure-contrib/monads library (the source of your compiling
error), which has since migrated to https://github.com/clojure/algo.monads.
It might take some work to resuscitate the library.

David


On May 17, 10:27 am, Lee Spector <lspec...@hampshire.edu> wrote:
> Thanks David.
>
> I found looking at the tests in infer's information_theory_test.clj to be useful as well.
>
> Unfortunately, when I try to use infer.information-theory I get errors, starting with:
>
> Exception in thread "main" java.lang.IllegalStateException: Can't dynamically bind non-dynamic var: clojure.contrib.macro-utils/protected-symbols, compiling:(clojure/contrib/monads.clj:195)
>
> This is after adding [infer "1.0-SNAPSHOT"] to the project.clj and doing lein deps, which seems to work. It's in a new clojure 1.4.0 project.
>
> Any ideas?
>
> Thanks,
>
>  -Lee
>
> On May 16, 2013, at 9:34 AM, David Edgar Liebke wrote:
>
>
>
>
>
>
>
> > Hi Lee,
>
> > The information-theory namespace was pulled out a while back and became part of the Infer library,http://github.com/aria42/infer.

Alex Ott

unread,
May 17, 2013, 3:11:30 PM5/17/13
to inca...@googlegroups.com
Yep, it looks like it heavily relied on clojure-contrib, although I've got at least compilable version :-)


--

---
You received this message because you are subscribed to the Google Groups "Incanter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to incanter+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.





--
With best wishes,                    Alex Ott
http://alexott.net/
Twitter: alexott_en (English), alexott (Russian)
Skype: alex.ott

Alex Ott

unread,
May 17, 2013, 4:02:12 PM5/17/13
to inca...@googlegroups.com, Lee Spector
Lee, you can grab code from https://github.com/alexott/infer - it was fixed for work with clojure 1.5.1


--

---
You received this message because you are subscribed to the Google Groups "Incanter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to incanter+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Lee Spector

unread,
May 18, 2013, 6:37:55 AM5/18/13
to Alex Ott, inca...@googlegroups.com

Thanks Alex!

-Lee
Reply all
Reply to author
Forward
0 new messages