Contents
Introduction
gomi is a software package for the evaluation of morphological intelligence measures on data. gomi includes all currently available morphological intelligence measures. This includes measures with continuous estimators as well as measures that use a discrete estimator.
The following sections will only provide minimal information about the measures. The goal of this post to provide information about the application of the measures, not an introduction of the measures themselves. For this purpose, please visit the other posts on these pages:
Posts:
- Morphological Computation: The Good, the Bad, and the Ugly
- Evaluating Morphological Computation in Muscle and DC-Motor Driven Models of Hopping Movements
- Quantifying morphological computation based on an information decomposition of the sensorimotor loop
- Quantifying Morphological Computation
or the following publications:
- K. Ghazi-Zahedi, D. F. B. Haeufle, G. F. Montufar, S. Schmitt, and N. Ay, “Evaluating morphological computation in muscle and dc-motor driven models of hopping movements,” Frontiers in robotics and ai, vol. 3, iss. 42, 2016.
[Bibtex]@article{Ghazi-Zahedi2016aEvaluating, Author = {Ghazi-Zahedi, Keyan and Haeufle, Daniel F.B. and Montufar, Guido Francisco and Schmitt, Syn and Ay, Nihat}, Issn = {2296-9144}, Journal = {Frontiers in Robotics and AI}, Number = {42}, Pdf = {http://www.frontiersin.org/computational_intelligence/10.3389/frobt.2016.00042/abstract}, Title = {Evaluating Morphological Computation in Muscle and DC-motor Driven Models of Hopping Movements}, Volume = {3}, Year = {2016}}
- K. Ghazi-Zahedi and J. Rauh, “Quantifying morphological computation based on an information decomposition of the sensorimotor loop,” in Proceedings of the 13th european conference on artificial life (ecal 2015), 2015, p. 70–-77.
[Bibtex]@inproceedings{Ghazi-Zahedi2015bQuantifying, Author = {Ghazi-Zahedi, Keyan and Rauh, Johannes}, Booktitle = {Proceedings of the 13th European Conference on Artificial Life (ECAL 2015)}, Date-Modified = {2018-05-26 22:52:07 +0000}, Month = {July}, Pages = {70---77}, Pdf = {http://keyan.ghazi-zahedi.eu/wp-content/uploads/2018/05/Ghazi-Zahedi2015aQuantifying-Morphological-Computation.pdf}, Read = {1}, Title = {Quantifying Morphological Computation based on an Information Decomposition of the Sensorimotor Loop}, Year = {2015}}
- K. Zahedi and N. Ay, “Quantifying morphological computation,” Entropy, vol. 15, iss. 5, p. 1887–1915, 2013.
[Bibtex]@article{Zahedi2013aQuantifying, Author = {Zahedi, Keyan and Ay, Nihat}, Issn = {1099-4300}, Journal = {Entropy}, Number = {5}, Pages = {1887--1915}, Pdf = {http://www.mdpi.com/1099-4300/15/5/1887}, Title = {Quantifying Morphological Computation}, Volume = {15}, Year = {2013}}
- K. Ghazi-Zahedi, R. Deimel, G. Montúfar, V. Wall, and O. Brock, “Morphological computation: the good, the bad, and the ugly,” in Iros 2017, 2017.
[Bibtex]@inproceedings{Ghazi-Zahedi2017aMorphological, Author = {Ghazi-Zahedi, Keyan and Deimel, Raphael and Mont{\'u}far, Guido and Wall, Vincent and Brock, Oliver}, Booktitle = {IROS 2017}, PDF = {https://ieeexplore.ieee.org/document/8202194/}, Title = {Morphological Computation: The Good, the Bad, and the Ugly}, Year = {2017}}
- K. Ghazi-Zahedi, C. Langer, and N. Ay, “Morphological computation: synergy of body and brain,” Entropy, vol. 19, iss. 9, 2017.
[Bibtex]@article{Ghazi-Zahedi2017bMorphological, Abstract = {There are numerous examples that show how the exploitation of the body's physical properties can lift the burden of the brain. Examples include grasping, swimming, locomotion, and motion detection. The term Morphological Computation was originally coined to describe processes in the body that would otherwise have to be conducted by the brain. In this paper, we argue for a synergistic perspective, and by that we mean that Morphological Computation is a process which requires a close interaction of body and brain. Based on a model of the sensorimotor loop, we study a new measure of synergistic information and show that it is more reliable in cases in which there is no synergistic information, compared to previous results. Furthermore, we discuss an algorithm that allows the calculation of the measure in non-trivial (non-binary) systems.}, Article = {456}, Author = {Ghazi-Zahedi, Keyan and Langer, Carlotta and Ay, Nihat}, Doi = {10.3390/e19090456}, Issn = {1099-4300}, Journal = {Entropy}, Number = {9}, Pdf = {http://www.mdpi.com/1099-4300/19/9/456/pdf}, Title = {Morphological Computation: Synergy of Body and Brain}, Url = {http://www.mdpi.com/1099-4300/19/9/456}, Volume = {19}, Year = {2017}, Bdsk-Url-1 = {http://www.mdpi.com/1099-4300/19/9/456}, Bdsk-Url-2 = {https://doi.org/10.3390/e19090456}}
Installation
gomi is written in Go. For the installation of Go, please read the installation documentation provided [here]. Pre-compiled binaries of gomi for Windows, Linux, and macOS are available in the release files [here].
Once Go is installed, gomi can easily be installed using the following commands:
1 |
go get github.com/kzahedi/gomi |
The following two packages are required and might have to be installed manually:
1 2 |
go get github.com/kzahedi/goent go get github.com/kzahedi/utils |
A zip (and tarball) of stable releases can be downloaded [here].
Discrete Measures
MI_W
To calculate this measure, we need to estimate the joint distribution from which the two conditional distributions can be calculated in the following way:
These calculations (which are required for the discrete estimator), are done automatically by gomi. The user only needs to provide the data and some parameters, which are explained next.
Using the gomi binary
To calculate MI_W with the binary, use the following command line parameters:
1 |
gomi -mi MI_W -file musfib.csv -wi 1,2,3 -ai 9 -v -bins 300 -o MI_W.csv |
The file musfib was used in [1] and can be downloaded [here].
Explanation of the command line options used in the example above:
-mi MI_W | Chooses MI_W as the measure |
-file musfib.csv | Data is provided in the file musfib.csv |
-wi 1,2,3 | Columns 1,2,3 of the data provided in musfib.csv define the world state (counting starts with 0) |
-ai 9 | Column 9 of the data provided in musfib.csv defines the action state (counting starts with 0) |
-v | gomi will print useful information while it is running and it will print the result |
-bins 300 | Global definition of the binning. This value will be used for each of the four columns |
-o MI_W.csv | The result and the specified parameters will be written to MI_W.csv |
The full list of command line options is given below.
Using gomi as a library
The measures implemented in gomi can also be used as a library. The following code snippet gives an example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
package main import ( "fmt" "github.com/kzahedi/goent/dh" goent "github.com/kzahedi/goent/discrete" mc "github.com/kzahedi/gomi/discrete" ) func main() { // W and A are just examples for data. These would usually be read from some data file // For this example to work, we provide some dummy data w := [][]float64{{0.0, 1.0}, {0.1, 1.1}, {0.2, 1.2}, {0.3, 1.3}, {0.4, 1.4}} a := [][]float64{{0.0, 1.0, 2.0}, {0.1, 1.1, 2.1}, {0.2, 1.2, 2.2}, {0.3, 1.3, 2.3}, {0.4, 1.4, 2.4}} // discretising data. Discrestise(data, bins for each column, min values for each column, max values for each column) wDiscretised := dh.Discretise(w, []int{10, 10}, []float64{0.0, 0.0}, []float64{1.0, 2.0}) aDiscretised := dh.Discretise(a, []int{10, 10, 10}, []float64{0.0, 0.0, 0.0}, []float64{1.0, 2.0, 3.0}) // univariate variables wUnivariate := dh.MakeUnivariateRelabelled(wDiscretised, []int{10, 10}) aUnivariate := dh.MakeUnivariateRelabelled(aDiscretised, []int{10, 10, 10}) // creating w', w, a data w2w1a1 := make([][]int, len(w)-1, len(w)-1) for i := 0; i < len(w)-1; i++ { w2w1a1[i] = make([]int, 3, 3) w2w1a1[i][0] = wUnivariate[i+1] w2w1a1[i][1] = wUnivariate[i] w2w1a1[i][2] = aUnivariate[i] } // calculating p(w',w,a) pw2w1a1 := goent.Emperical3D(w2w1a1) // calculating MI_W result := mc.MorphologicalComputationW(pw2w1a1) fmt.Println(result) } |
MI_A
To calculate this measure, we need to estimate the joint distribution from which the two conditional distributions can be calculated in the following way:
These calculations (which are required for the discrete estimator), are done automatically by gomi. The user only needs to provide the data and some parameters, which are explained next.
Using the gomi binary
To calculate MI_A with the binary, use the following command line parameters:
1 |
gomi -mi MI_A -file musfib.csv -wi 1,2,3 -ai 9 -v -bins 300 -o MI_A.csv |
The file musfib was used in [1] and can be downloaded [here].
Explanation of the command line options used in the example above:
-mi MI_A | Chooses MI_A as the measure |
-file musfib.csv | Data is provided in the file musfib.csv |
-wi 1,2,3 | Columns 1,2,3 of the data provided in musfib.csv define the world state (counting starts with 0) |
-ai 9 | Column 9 of the data provided in musfib.csv defines the action state (counting starts with 0) |
-v | gomi will print useful information while it is running and it will print the result |
-bins 300 | Global definition of the binning. This value will be used for each of the four columns |
-o MI_A.csv | The result and the specified parameters will be written to MI_A.csv |
The full list of command line options is given below.
Using gomi as a library
The measures implemented in gomi can also be used as a library. The following code snippet gives an example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
package main import ( "fmt" "github.com/kzahedi/goent/dh" goent "github.com/kzahedi/goent/discrete" mc "github.com/kzahedi/gomi/discrete" ) func main() { // W and A are just examples for data. These would usually be read from some data file // For this example to work, we provide some dummy data w := [][]float64{{0.0, 1.0}, {0.1, 1.1}, {0.2, 1.2}, {0.3, 1.3}, {0.4, 1.4}} a := [][]float64{{0.0, 1.0, 2.0}, {0.1, 1.1, 2.1}, {0.2, 1.2, 2.2}, {0.3, 1.3, 2.3}, {0.4, 1.4, 2.4}} // discretising data. Discrestise(data, bins for each column, min values for each column, max values for each column) wDiscretised := dh.Discretise(w, []int{10, 10}, []float64{0.0, 0.0}, []float64{1.0, 2.0}) aDiscretised := dh.Discretise(a, []int{10, 10, 10}, []float64{0.0, 0.0, 0.0}, []float64{1.0, 2.0, 3.0}) // univariate variables wUnivariate := dh.MakeUnivariateRelabelled(wDiscretised, []int{10, 10}) aUnivariate := dh.MakeUnivariateRelabelled(aDiscretised, []int{10, 10, 10}) // creating w', w, a data w2a1w1 := make([][]int, len(w)-1, len(w)-1) for i := 0; i < len(w)-1; i++ { w2a1w1[i] = make([]int, 3, 3) w2a1w1[i][0] = wUnivariate[i+1] w2a1w1[i][1] = aUnivariate[i] w2a1w1[i][2] = wUnivariate[i] } // calculating p(w',a,w) pw2a1w1 := goent.Emperical3D(w2a1w1) // calculating MI_A result := mc.MorphologicalComputationA(pw2a1w1) fmt.Println(result) } |
MI_A_Prime
This is a version of the previous measure that increases with increasing effect of W on W’. It is normalised to one.
Using the gomi binary
To calculate MI_A_Prime with the binary, use the following command line parameters:
1 |
gomi -mi MI_A_Prime -file musfib.csv -wi 1,2,3 -ai 9 -v -bins 300 -o MI_A_Prime.csv |
The file musfib was used in [1] and can be downloaded [here].
Explanation of the command line options used in the example above:
-mi MI_A_Prime | Chooses MI_A_Prime as the measure |
-file musfib.csv | Data is provided in the file musfib.csv |
-wi 1,2,3 | Columns 1,2,3 of the data provided in musfib.csv define the world state (counting starts with 0) |
-ai 9 | Column 9 of the data provided in musfib.csv defines the action state (counting starts with 0) |
-v | gomi will print useful information while it is running and it will print the result |
-bins 300 | Global definition of the binning. This value will be used for each of the four columns |
-o MI_A_Prime.csv | The result and the specified parameters will be written to MI_A_Prime.csv |
The full list of command line options is given below.
Using gomi as a library
The measures implemented in gomi can also be used as a library. The following code snippet gives an example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
package main import ( "fmt" "math" "github.com/kzahedi/goent/dh" goent "github.com/kzahedi/goent/discrete" mc "github.com/kzahedi/gomi/discrete" ) func main() { // W and A are just examples for data. These would usually be read from some data file // For this example to work, we provide some dummy data w := [][]float64{{0.0, 1.0}, {0.1, 1.1}, {0.2, 1.2}, {0.3, 1.3}, {0.4, 1.4}} a := [][]float64{{0.0, 1.0, 2.0}, {0.1, 1.1, 2.1}, {0.2, 1.2, 2.2}, {0.3, 1.3, 2.3}, {0.4, 1.4, 2.4}} // discretising data. Discrestise(data, bins for each column, min values for each column, max values for each column) wDiscretised := dh.Discretise(w, []int{10, 10}, []float64{0.0, 0.0}, []float64{1.0, 2.0}) aDiscretised := dh.Discretise(a, []int{10, 10, 10}, []float64{0.0, 0.0, 0.0}, []float64{1.0, 2.0, 3.0}) // univariate variables wUnivariate := dh.MakeUnivariateRelabelled(wDiscretised, []int{10, 10}) aUnivariate := dh.MakeUnivariateRelabelled(aDiscretised, []int{10, 10, 10}) // creating w', w, a data w2a1w1 := make([][]int, len(w)-1, len(w)-1) for i := 0; i < len(w)-1; i++ { w2a1w1[i] = make([]int, 3, 3) w2a1w1[i][0] = wUnivariate[i+1] w2a1w1[i][1] = aUnivariate[i] w2a1w1[i][2] = wUnivariate[i] } // calculating p(w',a,w) pw2a1w1 := goent.Emperical3D(w2a1w1) abins := 10.0 * 10.0 * 10.0 // see aDiscretised above // calculating MI_A_Prime result := 1.0 - 1.0/math.Log2(abins) - mc.MorphologicalComputationA(pw2a1w1) fmt.Println(result) } |
MI_MI
Using the gomi binary
To calculate MI_MI with the binary, use the following command line parameters:
1 |
gomi -mi MI_MI -file musfib.csv -wi 1,2,3 -ai 9 -si 4 -v -bins 300 -o MI_MI.csv |
The file musfib was used in [1] and can be downloaded [here].
Explanation of the command line options used in the example above:
-mi MI_MI | Chooses MI_MI as the measure |
-file musfib.csv | Data is provided in the file musfib.csv |
-wi 1,2,3 | Columns 1,2,3 of the data provided in musfib.csv define the world state (counting starts with 0) |
-ai 9 | Column 9 of the data provided in musfib.csv defines the action state (counting starts with 0) |
-si 4 | Column 4 of the data provided in musfib.csv defines the sensor state (counting starts with 0) |
-v | gomi will print useful information while it is running and it will print the result |
-bins 300 | Global definition of the binning. This value will be used for each of the four columns |
-o MI_MI.csv | The result and the specified parameters will be written to MI_MI.csv |
The full list of command line options is given below.
Using gomi as a library
The measures implemented in gomi can also be used as a library. The following code snippet gives an example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
package main import ( "fmt" "github.com/kzahedi/goent/dh" goent "github.com/kzahedi/goent/discrete" mc "github.com/kzahedi/gomi/discrete" ) func main() { // W, A, and S are just examples for data. These would usually be read from some data file // For this example to work, we provide some dummy data w := [][]float64{{0.0, 1.0}, {0.1, 1.1}, {0.2, 1.2}, {0.3, 1.3}, {0.4, 1.4}} a := [][]float64{{0.0, 1.0, 2.0}, {0.1, 1.1, 2.1}, {0.2, 1.2, 2.2}, {0.3, 1.3, 2.3}, {0.4, 1.4, 2.4}} s := [][]float64{{0.0}, {0.1}, {0.2}, {0.3}, {0.4}} // discretising data. Discrestise(data, bins for each column, min values for each column, max values for each column) wDiscretised := dh.Discretise(w, []int{10, 10}, []float64{0.0, 0.0}, []float64{1.0, 2.0}) aDiscretised := dh.Discretise(a, []int{10, 10, 10}, []float64{0.0, 0.0, 0.0}, []float64{1.0, 2.0, 3.0}) sDiscretised := dh.Discretise(s, []int{10}, []float64{0.0}, []float64{1.0}) // univariate variables wUnivariate := dh.MakeUnivariateRelabelled(wDiscretised, []int{10, 10}) aUnivariate := dh.MakeUnivariateRelabelled(aDiscretised, []int{10, 10, 10}) sUnivariate := dh.MakeUnivariateRelabelled(sDiscretised, []int{10}) // creating w', w and a, s data w2w1 := make([][]int, len(w)-1, len(w)-1) a1s1 := make([][]int, len(w)-1, len(w)-1) for i := 0; i < len(w)-1; i++ { w2w1[i] = make([]int, 2, 2) w2w1[i][0] = wUnivariate[i+1] w2w1[i][1] = wUnivariate[i] a1s1[i] = make([]int, 2, 2) a1s1[i][0] = aUnivariate[1] a1s1[i][1] = sUnivariate[i] } // calculating p(w',w) and p(a,s) pw2w1 := goent.Emperical2D(w2w1) pa1s1 := goent.Emperical2D(w2w1) // calculating MI_MI result := mc.MorphologicalComputationMI(pw2w1, pa1s1) fmt.Println(result) } |
MI_CA
Using the gomi binary
To calculate MI_CA with the binary, use the following command line parameters:
1 |
gomi -mi MI_CA -file musfib.csv -wi 1,2,3 -ai 9 -v -bins 300 -o MI_CA.csv |
The file musfib was used in [1] and can be downloaded [here].
Explanation of the command line options used in the example above:
-mi MI_CA | Chooses MI_CA as the measure |
-file musfib.csv | Data is provided in the file musfib.csv |
-wi 1,2,3 | Columns 1,2,3 of the data provided in musfib.csv define the world state (counting starts with 0) |
-ai 9 | Column 9 of the data provided in musfib.csv defines the action state (counting starts with 0) |
-v | gomi will print useful information while it is running and it will print the result |
-bins 300 | Global definition of the binning. This value will be used for each of the four columns |
-o MI_CA.csv | The result and the specified parameters will be written to MI_CA.csv |
The full list of command line options is given below.
Using gomi as a library
The measures implemented in gomi can also be used as a library. The following code snippet gives an example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
package main import ( "fmt" "github.com/kzahedi/goent/dh" goent "github.com/kzahedi/goent/discrete" mc "github.com/kzahedi/gomi/discrete" ) func main() { // W and A are just examples for data. These would usually be read from some data file // For this example to work, we provide some dummy data w := [][]float64{{0.0, 1.0}, {0.1, 1.1}, {0.2, 1.2}, {0.3, 1.3}, {0.4, 1.4}} a := [][]float64{{0.0, 1.0, 2.0}, {0.1, 1.1, 2.1}, {0.2, 1.2, 2.2}, {0.3, 1.3, 2.3}, {0.4, 1.4, 2.4}} // discretising data. Discrestise(data, bins for each column, min values for each column, max values for each column) wDiscretised := dh.Discretise(w, []int{10, 10}, []float64{0.0, 0.0}, []float64{1.0, 2.0}) aDiscretised := dh.Discretise(a, []int{10, 10, 10}, []float64{0.0, 0.0, 0.0}, []float64{1.0, 2.0, 3.0}) // univariate variables wUnivariate := dh.MakeUnivariateRelabelled(wDiscretised, []int{10, 10}) aUnivariate := dh.MakeUnivariateRelabelled(aDiscretised, []int{10, 10, 10}) // creating w', w, and w', a data w2w1 := make([][]int, len(w)-1, len(w)-1) w2a1 := make([][]int, len(w)-1, len(w)-1) for i := 0; i < len(w)-1; i++ { w2w1[i] = make([]int, 2, 2) w2w1[i][0] = wUnivariate[i+1] w2w1[i][1] = wUnivariate[i] w2a1[i] = make([]int, 2, 2) w2a1[i][0] = wUnivariate[1+1] w2a1[i][1] = aUnivariate[i] } // calculating p(w',w,a) pw2w1 := goent.Emperical2D(w2w1) pw2a1 := goent.Emperical2D(w2a1) // calculating MI_CA result := mc.MorphologicalComputationCA(pw2w1, pw2a1) fmt.Println(result) } |
MI_WA
Using the gomi binary
To calculate MI_WA with the binary, use the following command line parameters:
1 |
gomi -mi MI_WA -file musfib.csv -wi 1,2,3 -ai 9 -v -bins 300 -o MI_WA.csv |
The file musfib was used in [1] and can be downloaded [here].
Explanation of the command line options used in the example above:
-mi MI_WA | Chooses MI_WA as the measure |
-file musfib.csv | Data is provided in the file musfib.csv |
-wi 1,2,3 | Columns 1,2,3 of the data provided in musfib.csv define the world state (counting starts with 0) |
-ai 9 | Column 9 of the data provided in musfib.csv defines the action state (counting starts with 0) |
-v | gomi will print useful information while it is running and it will print the result |
-bins 300 | Global definition of the binning. This value will be used for each of the four columns |
-o MI_WA.csv | The result and the specified parameters will be written to MI_WA.csv |
The full list of command line options is given below.
Using gomi as a library
The measures implemented in gomi can also be used as a library. The following code snippet gives an example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
package main import ( "fmt" "github.com/kzahedi/goent/dh" goent "github.com/kzahedi/goent/discrete" mc "github.com/kzahedi/gomi/discrete" ) func main() { // W and A are just examples for data. These would usually be read from some data file // For this example to work, we provide some dummy data w := [][]float64{{0.0, 1.0}, {0.1, 1.1}, {0.2, 1.2}, {0.3, 1.3}, {0.4, 1.4}} a := [][]float64{{0.0, 1.0, 2.0}, {0.1, 1.1, 2.1}, {0.2, 1.2, 2.2}, {0.3, 1.3, 2.3}, {0.4, 1.4, 2.4}} // discretising data. Discrestise(data, bins for each column, min values for each column, max values for each column) wDiscretised := dh.Discretise(w, []int{10, 10}, []float64{0.0, 0.0}, []float64{1.0, 2.0}) aDiscretised := dh.Discretise(a, []int{10, 10, 10}, []float64{0.0, 0.0, 0.0}, []float64{1.0, 2.0, 3.0}) // univariate variables wUnivariate := dh.MakeUnivariateRelabelled(wDiscretised, []int{10, 10}) aUnivariate := dh.MakeUnivariateRelabelled(aDiscretised, []int{10, 10, 10}) // creating w', w, a data w2w1a1 := make([][]int, len(w)-1, len(w)-1) for i := 0; i < len(w)-1; i++ { w2w1a1[i] = make([]int, 3, 3) w2w1a1[i][0] = wUnivariate[i+1] w2w1a1[i][1] = wUnivariate[i] w2w1a1[i][2] = aUnivariate[i] } // calculating p(w',w,a) pw2w1a1 := goent.Emperical3D(w2w1a1) // calculating MI_WA result := mc.MorphologicalComputationWA(pw2w1a1) fmt.Println(result) } |
MI_WS
Using the gomi binary
To calculate MI_WS with the binary, use the following command line parameters:
1 |
gomi -mi MI_WS -file musfib.csv -wi 1,2,3 -si 4 -v -bins 300 -o MI_WS.csv |
The file musfib was used in [1] and can be downloaded [here].
Explanation of the command line options used in the example above:
-mi MI_WS | Chooses MI_WS as the measure |
-file musfib.csv | Data is provided in the file musfib.csv |
-wi 1,2,3 | Columns 1,2,3 of the data provided in musfib.csv define the world state (counting starts with 0) |
-si 4 | Column 4 of the data provided in musfib.csv defines the sensor state (counting starts with 0) |
-v | gomi will print useful information while it is running and it will print the result |
-bins 300 | Global definition of the binning. This value will be used for each of the four columns |
-o MI_WS.csv | The result and the specified parameters will be written to MI_WS.csv |
The full list of command line options is given below.
Using gomi as a library
The measures implemented in gomi can also be used as a library. The following code snippet gives an example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
package main import ( "fmt" "github.com/kzahedi/goent/dh" goent "github.com/kzahedi/goent/discrete" mc "github.com/kzahedi/gomi/discrete" ) func main() { // W and S are just examples for data. These would usually be read from some data file // For this example to work, we provide some dummy data w := [][]float64{{0.0, 1.0}, {0.1, 1.1}, {0.2, 1.2}, {0.3, 1.3}, {0.4, 1.4}} s := [][]float64{{0.0, 1.0, 2.0}, {0.1, 1.1, 2.1}, {0.2, 1.2, 2.2}, {0.3, 1.3, 2.3}, {0.4, 1.4, 2.4}} // discretising data. Discrestise(data, bins for each column, min values for each column, max values for each column) wDiscretised := dh.Discretise(w, []int{10, 10}, []float64{0.0, 0.0}, []float64{1.0, 2.0}) sDiscretised := dh.Discretise(s, []int{10, 10, 10}, []float64{0.0, 0.0, 0.0}, []float64{1.0, 2.0, 3.0}) // univariate variables wUnivariate := dh.MakeUnivariateRelabelled(wDiscretised, []int{10, 10}) sUnivariate := dh.MakeUnivariateRelabelled(sDiscretised, []int{10, 10, 10}) // creating w', w, s data w2w1s1 := make([][]int, len(w)-1, len(w)-1) for i := 0; i < len(w)-1; i++ { w2w1s1[i] = make([]int, 3, 3) w2w1s1[i][0] = wUnivariate[i+1] w2w1s1[i][1] = wUnivariate[i] w2w1s1[i][2] = sUnivariate[i] } // calculating p(w',w,s) pw2w1s1 := goent.Emperical3D(w2w1s1) // calculating MI_WS result := mc.MorphologicalComputationWS(pw2w1s1) fmt.Println(result) } |
MI_IN
Using the gomi binary
To calculate MI_MI with the binary, use the following command line parameters:
1 |
gomi -mi MI_IN -file musfib.csv -si 4 -ai 9 -v -bins 300 -o MI_IN.csv |
The file musfib was used in [1] and can be downloaded [here].
Explanation of the command line options used in the example above:
-mi MI_IN | Chooses MI_IN as the measure |
-file musfib.csv | Data is provided in the file musfib.csv |
-si 4 | Columns 4 of the data provided in musfib.csv define the sensor state (counting starts with 0) |
-ai 9 | Column 9 of the data provided in musfib.csv defines the action state (counting starts with 0) |
-v | gomi will print useful information while it is running and it will print the result |
-bins 300 | Global definition of the binning. This value will be used for each of the four columns |
-o MI_IN.csv | The result and the specified parameters will be written to MI_IN.csv |
The full list of command line options is given below.
Using gomi as a library
The measures implemented in gomi can also be used as a library. The following code snippet gives an example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
package main import ( "fmt" "github.com/kzahedi/goent/dh" goent "github.com/kzahedi/goent/discrete" mc "github.com/kzahedi/gomi/discrete" ) func main() { // A and S are just examples for data. These would usually be read from some data file // For this example to work, we provide some dummy data a := [][]float64{{0.0, 1.0, 2.0}, {0.1, 1.1, 2.1}, {0.2, 1.2, 2.2}, {0.3, 1.3, 2.3}, {0.4, 1.4, 2.4}} s := [][]float64{{0.0}, {0.1}, {0.2}, {0.3}, {0.4}} // discretising data. Discrestise(data, bins for each column, min values for each column, max values for each column) aDiscretised := dh.Discretise(a, []int{10, 10, 10}, []float64{0.0, 0.0, 0.0}, []float64{1.0, 2.0, 3.0}) sDiscretised := dh.Discretise(s, []int{10}, []float64{0.0}, []float64{1.0}) // univariate variables aUnivariate := dh.MakeUnivariateRelabelled(aDiscretised, []int{10, 10, 10}) sUnivariate := dh.MakeUnivariateRelabelled(sDiscretised, []int{10}) // creating s, a data a1s1 := make([][]int, len(a)-1, len(a)-1) for i := 0; i < len(a)-1; i++ { a1s1[i] = make([]int, 2, 2) a1s1[i][0] = aUnivariate[1] a1s1[i][1] = sUnivariate[i] } // calculating p(a,s) pa1s1 := goent.Emperical2D(a1s1) abins := 10 * 10 * 10 // see aDiscretised above // calculating MI_IN result := mc.MorphologicalComputationIN(pa1s1, abins) fmt.Println(result) } |
CA
Using the gomi binary
To calculate CA with the binary, use the following command line parameters:
1 |
gomi -mi CA -file musfib.csv -si 4 -ai 9 -v -bins 300 -o CA.csv |
The file musfib was used in [1] and can be downloaded [here].
Explanation of the command line options used in the example above:
-mi CA | Chooses CA as the measure |
-file musfib.csv | Data is provided in the file musfib.csv |
-si 4 | Columns 4 of the data provided in musfib.csv define the sensor state (counting starts with 0) |
-ai 9 | Column 9 of the data provided in musfib.csv defines the action state (counting starts with 0) |
-v | gomi will print useful information while it is running and it will print the result |
-bins 300 | Global definition of the binning. This value will be used for each of the four columns |
-o CA.csv | The result and the specified parameters will be written to CA.csv |
The full list of command line options is given below.
Using gomi as a library
The measures implemented in gomi can also be used as a library. The following code snippet gives an example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
package main import ( "fmt" "github.com/kzahedi/goent/dh" goent "github.com/kzahedi/goent/discrete" mc "github.com/kzahedi/gomi/discrete" ) func main() { // S and A are just examples for data. These would usually be read from some data file // For this example to work, we provide some dummy data s := [][]float64{{0.0, 1.0}, {0.1, 1.1}, {0.2, 1.2}, {0.3, 1.3}, {0.4, 1.4}} a := [][]float64{{0.0, 1.0, 2.0}, {0.1, 1.1, 2.1}, {0.2, 1.2, 2.2}, {0.3, 1.3, 2.3}, {0.4, 1.4, 2.4}} // discretising data. Discrestise(data, bins for each column, min values for each column, max values for each column) sDiscretised := dh.Discretise(s, []int{10, 10}, []float64{0.0, 0.0}, []float64{1.0, 2.0}) aDiscretised := dh.Discretise(a, []int{10, 10, 10}, []float64{0.0, 0.0, 0.0}, []float64{1.0, 2.0, 3.0}) // univariate variables sUnivariate := dh.MakeUnivariateRelabelled(sDiscretised, []int{10, 10}) aUnivariate := dh.MakeUnivariateRelabelled(aDiscretised, []int{10, 10, 10}) // creating s', s, a data s2s1a1 := make([][]int, len(s)-1, len(s)-1) for i := 0; i < len(a)-1; i++ { s2s1a1[i] = make([]int, 3, 3) s2s1a1[i][0] = sUnivariate[i+1] s2s1a1[i][1] = sUnivariate[i] s2s1a1[i][2] = aUnivariate[i] } // calculating p(w',w,a) ps2s1a1 := goent.Emperical3D(s2s1a1) sbins := 10 * 10 // see sDiscretised above // calculating CA result := mc.MorphologicalComputationIntrinsicCA(ps2s1a1, sbins) fmt.Println(result) } |
MI_SY
Using the gomi binary
To calculate MI_SY with the binary, use the following command line parameters:
1 |
gomi -mi MI_SY -file musfib.csv -wi 1,2,3 -ai 9 -v -bins 300 -o MI_SY.csv |
The file musfib was used in [1] and can be downloaded [here].
Explanation of the command line options used in the example above:
-mi MI_SY | Chooses MI_SY as the measure |
-file musfib.csv | Data is provided in the file musfib.csv |
-wi 1,2,3 | Columns 1,2,3 of the data provided in musfib.csv define the world state (counting starts with 0) |
-ai 9 | Column 9 of the data provided in musfib.csv defines the action state (counting starts with 0) |
-v | gomi will print useful information while it is running and it will print the result |
-bins 300 | Global definition of the binning. This value will be used for each of the four columns |
-o MI_SY.csv | The result and the specified parameters will be written to MI_SY.csv |
The full list of command line options is given below.
Using gomi as a library
The measures implemented in gomi can also be used as a library. The following code snippet gives an example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
package main import ( "fmt" "github.com/kzahedi/goent/dh" goent "github.com/kzahedi/goent/discrete" mc "github.com/kzahedi/gomi/discrete" ) func main() { // W and A are just examples for data. These would usually be read from some data file // For this example to work, we provide some dummy data w := [][]float64{{0.0, 1.0}, {0.1, 1.1}, {0.2, 1.2}, {0.3, 1.3}, {0.4, 1.4}} a := [][]float64{{0.0, 1.0, 2.0}, {0.1, 1.1, 2.1}, {0.2, 1.2, 2.2}, {0.3, 1.3, 2.3}, {0.4, 1.4, 2.4}} // discretising data. Discrestise(data, bins for each column, min values for each column, max values for each column) wDiscretised := dh.Discretise(w, []int{10, 10}, []float64{0.0, 0.0}, []float64{1.0, 2.0}) aDiscretised := dh.Discretise(a, []int{10, 10, 10}, []float64{0.0, 0.0, 0.0}, []float64{1.0, 2.0, 3.0}) // univariate variables wUnivariate := dh.MakeUnivariateRelabelled(wDiscretised, []int{10, 10}) aUnivariate := dh.MakeUnivariateRelabelled(aDiscretised, []int{10, 10, 10}) // creating w', w, a data w2w1a1 := make([][]int, len(w)-1, len(w)-1) for i := 0; i < len(w)-1; i++ { w2w1a1[i] = make([]int, 3, 3) w2w1a1[i][0] = wUnivariate[i+1] w2w1a1[i][1] = wUnivariate[i] w2w1a1[i][2] = aUnivariate[i] } // calculating p(w',w,a) pw2w1a1 := goent.Emperical3D(w2w1a1) // calculating MI_W iterations := 1000 verbose := true result := mc.MorphologicalComputationSY(pw2w1a1, iterations, verbose) fmt.Println(result) } |
MI_SY_NID
without including the input distribution p(w,a).
Using the gomi binary
To calculate MI_SY_NID with the binary, use the following command line parameters:
1 |
gomi -mi MI_SY_NID -file musfib.csv -wi 1,2,3 -ai 9 -v -bins 300 -o MI_SY_NID.csv |
The file musfib was used in [1] and can be downloaded [here].
Explanation of the command line options used in the example above:
-mi MI_SY_NID | Chooses MI_SY_NID as the measure |
-file musfib.csv | Data is provided in the file musfib.csv |
-wi 1,2,3 | Columns 1,2,3 of the data provided in musfib.csv define the world state (counting starts with 0) |
-ai 9 | Column 9 of the data provided in musfib.csv defines the action state (counting starts with 0) |
-v | gomi will print useful information while it is running and it will print the result |
-bins 300 | Global definition of the binning. This value will be used for each of the four columns |
-o MI_SY_NID.csv | The result and the specified parameters will be written to MI_SY_NID.csv |
The full list of command line options is given below.
Using gomi as a library
The measures implemented in gomi can also be used as a library. The following code snippet gives an example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
package main import ( "fmt" "github.com/kzahedi/goent/dh" goent "github.com/kzahedi/goent/discrete" mc "github.com/kzahedi/gomi/discrete" ) func main() { // W and A are just examples for data. These would usually be read from some data file // For this example to work, we provide some dummy data w := [][]float64{{0.0, 1.0}, {0.1, 1.1}, {0.2, 1.2}, {0.3, 1.3}, {0.4, 1.4}} a := [][]float64{{0.0, 1.0, 2.0}, {0.1, 1.1, 2.1}, {0.2, 1.2, 2.2}, {0.3, 1.3, 2.3}, {0.4, 1.4, 2.4}} // discretising data. Discrestise(data, bins for each column, min values for each column, max values for each column) wDiscretised := dh.Discretise(w, []int{10, 10}, []float64{0.0, 0.0}, []float64{1.0, 2.0}) aDiscretised := dh.Discretise(a, []int{10, 10, 10}, []float64{0.0, 0.0, 0.0}, []float64{1.0, 2.0, 3.0}) // univariate variables wUnivariate := dh.MakeUnivariateRelabelled(wDiscretised, []int{10, 10}) aUnivariate := dh.MakeUnivariateRelabelled(aDiscretised, []int{10, 10, 10}) // creating w', w, a data w2w1a1 := make([][]int, len(w)-1, len(w)-1) for i := 0; i < len(w)-1; i++ { w2w1a1[i] = make([]int, 3, 3) w2w1a1[i][0] = wUnivariate[i+1] w2w1a1[i][1] = wUnivariate[i] w2w1a1[i][2] = aUnivariate[i] } // calculating p(w',w,a) pw2w1a1 := goent.Emperical3D(w2w1a1) // calculating MI_W iterations := 1000 verbose := true result := mc.MorphologicalComputationSyNid(pw2w1a1, iterations, verbose) fmt.Println(result) } |
Continuous Measures
MI_W
where I(W’;W|A) uses the Frenzel-Pompe estimator on continuous data.
Using the gomi binary
To calculate MI_W with the binary, use the following command line parameters:
1 |
gomi -mi MI_W -file musfib.csv -wi 1,2,3 -ai 9 -v -c -o MI_W.csv |
The file musfib was used in [1] and can be downloaded [here].
Explanation of the command line options used in the example above:
-mi MI_W | Chooses MI_W as the measure |
-file musfib.csv | Data is provided in the file musfib.csv |
-wi 1,2,3 | Columns 1,2,3 of the data provided in musfib.csv define the world state (counting starts with 0) |
-ai 9 | Column 9 of the data provided in musfib.csv defines the action state (counting starts with 0) |
-v | gomi will print useful information while it is running and it will print the result |
-c | gomi will Frenzel-Pompe estimator for conditional mutual information |
-o MI_W.csv | The result and the specified parameters will be written to MI_W.csv |
The full list of command line options is given below.
Using gomi as a library
The measures implemented in gomi can also be used as a library. The following code snippet gives an example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
package main import ( "fmt" "math/rand" goent "github.com/kzahedi/goent/continuous" mc "github.com/kzahedi/gomi/continuous" ) func main() { // W and A are just examples for data. These would usually be read from some data file // For this example to work, we provide some dummy data wDim := 2 w := make([][]float64, 1000, 1000) for i := 0; i < 1000; i++ { w[i] = make([]float64, wDim, wDim) w[i][0] = rand.Float64() w[i][1] = rand.Float64() } aDim := 3 a := make([][]float64, 1000, 1000) for i := 0; i < 1000; i++ { a[i] = make([]float64, aDim, aDim) a[i][0] = rand.Float64() a[i][1] = rand.Float64() a[i][2] = rand.Float64() } // creating w', w, a data w2w1a1 := make([][]float64, 999, 999) for i := 0; i < len(w)-1; i++ { w2w1a1[i] = make([]float64, 2*wDim+aDim, 2*wDim+aDim) // w' w2w1a1[i][0] = w[i+1][0] w2w1a1[i][1] = w[i+1][1] // w w2w1a1[i][2] = w[i][0] w2w1a1[i][3] = w[i][1] // a w2w1a1[i][4] = a[i][0] w2w1a1[i][5] = a[i][1] w2w1a1[i][6] = a[i][2] } w2w1a1 = goent.Normalise(w2w1a1, false) // calculating MI_W w2indices := []int{0, 1} w1indices := []int{2, 3} a1indices := []int{4, 5, 6} k := 30 verbose := true result := mc.MorphologicalComputationW(w2w1a1, w2indices, w1indices, a1indices, k, verbose) fmt.Println(result) } |
MI_A
where I(W’;A|W) uses the Frenzel-Pompe estimator on continuous data.
Using the gomi binary
To calculate MI_A with the binary, use the following command line parameters:
1 |
gomi -mi MI_A -file musfib.csv -wi 1,2,3 -ai 9 -v -c -o MI_A.csv |
The file musfib was used in [1] and can be downloaded [here].
Explanation of the command line options used in the example above:
-mi MI_A | Chooses MI_A as the measure |
-file musfib.csv | Data is provided in the file musfib.csv |
-wi 1,2,3 | Columns 1,2,3 of the data provided in musfib.csv define the world state (counting starts with 0) |
-ai 9 | Column 9 of the data provided in musfib.csv defines the action state (counting starts with 0) |
-v | gomi will print useful information while it is running and it will print the result |
-c | gomi will Frenzel-Pompe estimator for conditional mutual information |
-o MI_A.csv | The result and the specified parameters will be written to MI_A.csv |
The full list of command line options is given below.
Using gomi as a library
The measures implemented in gomi can also be used as a library. The following code snippet gives an example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
package main import ( "fmt" "math/rand" goent "github.com/kzahedi/goent/continuous" mc "github.com/kzahedi/gomi/continuous" ) func main() { // W and A are just examples for data. These would usually be read from some data file // For this example to work, we provide some dummy data wDim := 2 w := make([][]float64, 1000, 1000) for i := 0; i < 1000; i++ { w[i] = make([]float64, wDim, wDim) w[i][0] = rand.Float64() w[i][1] = rand.Float64() } aDim := 3 a := make([][]float64, 1000, 1000) for i := 0; i < 1000; i++ { a[i] = make([]float64, aDim, aDim) a[i][0] = rand.Float64() a[i][1] = rand.Float64() a[i][2] = rand.Float64() } // creating w', w, a data w2w1a1 := make([][]float64, 999, 999) for i := 0; i < len(w)-1; i++ { w2w1a1[i] = make([]float64, 2*wDim+aDim, 2*wDim+aDim) // w' w2w1a1[i][0] = w[i+1][0] w2w1a1[i][1] = w[i+1][1] // w w2w1a1[i][2] = w[i][0] w2w1a1[i][3] = w[i][1] // a w2w1a1[i][4] = a[i][0] w2w1a1[i][5] = a[i][1] w2w1a1[i][6] = a[i][2] } w2w1a1 = goent.Normalise(w2w1a1, false) // calculating MI_W w2indices := []int{0, 1} w1indices := []int{2, 3} a1indices := []int{4, 5, 6} k := 30 verbose := true result := mc.MorphologicalComputationA(w2w1a1, w2indices, w1indices, a1indices, k, verbose) fmt.Println(result) } |
MI_MI
where I(W’;A) and I(A;S) use the KSG estimator for mutual information on continuous data.
Using the gomi binary
To calculate MI_MI with the binary, use the following command line parameters:
1 |
gomi -mi MI_MI -file musfib.csv -wi 1,2,3 -ai 9 -si 4 -v -c -cm 2 -o MI_MI.csv |
The file musfib was used in [1] and can be downloaded [here].
Explanation of the command line options used in the example above:
-mi MI_MI | Chooses MI_MI as the measure |
-file musfib.csv | Data is provided in the file musfib.csv |
-wi 1,2,3 | Columns 1,2,3 of the data provided in musfib.csv define the world state (counting starts with 0) |
-ai 9 | Column 9 of the data provided in musfib.csv defines the action state (counting starts with 0) |
-si 4 | Column 4 of the data provided in musfib.csv defines the sensor state (counting starts with 0) |
-v | gomi will print useful information while it is running and it will print the result |
-c | gomi will use the KSG Estimator for mutual information. |
-cm 2 | gomi will use the KSG Estimator 2 for mutual information. KSG 1 estimator can be chosen with -cm 1 |
-o MI_MI.csv | The result and the specified parameters will be written to MI_MI.csv |
The full list of command line options is given below.
Using gomi as a library
The measures implemented in gomi can also be used as a library. The following code snippet gives an example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
package main import ( "fmt" "math/rand" goent "github.com/kzahedi/goent/continuous" mc "github.com/kzahedi/gomi/continuous" ) func main() { // W and A are just examples for data. These would usually be read from some data file // For this example to work, we provide some dummy data wDim := 2 w := make([][]float64, 1000, 1000) for i := 0; i < 1000; i++ { w[i] = make([]float64, wDim, wDim) w[i][0] = rand.Float64() w[i][1] = rand.Float64() } aDim := 3 a := make([][]float64, 1000, 1000) for i := 0; i < 1000; i++ { a[i] = make([]float64, aDim, aDim) a[i][0] = rand.Float64() a[i][1] = rand.Float64() a[i][2] = rand.Float64() } sDim := 5 s := make([][]float64, 1000, 1000) for i := 0; i < 1000; i++ { s[i] = make([]float64, sDim, sDim) s[i][0] = rand.Float64() s[i][1] = rand.Float64() s[i][2] = rand.Float64() s[i][3] = rand.Float64() s[i][4] = rand.Float64() } // creating w', w, a data w2w1s1a1 := make([][]float64, 999, 999) for i := 0; i < len(w)-1; i++ { w2w1s1a1[i] = make([]float64, 2*wDim+sDim+aDim, 2*wDim+sDim+aDim) // w' w2w1s1a1[i][0] = w[i+1][0] w2w1s1a1[i][1] = w[i+1][1] // w w2w1s1a1[i][2] = w[i][0] w2w1s1a1[i][3] = w[i][1] // s w2w1s1a1[i][4] = s[i][0] w2w1s1a1[i][5] = s[i][1] w2w1s1a1[i][6] = s[i][2] w2w1s1a1[i][7] = s[i][3] w2w1s1a1[i][8] = s[i][4] // a w2w1s1a1[i][9] = a[i][0] w2w1s1a1[i][10] = a[i][1] w2w1s1a1[i][11] = a[i][2] } w2w1s1a1 = goent.Normalise(w2w1s1a1, false) // calculating MI_MI w2indices := []int{0, 1} w1indices := []int{2, 3} s1indices := []int{4, 5, 6, 7, 8} a1indices := []int{9, 10, 11} k := 30 verbose := true result1 := mc.MorphologicalComputationMI1(w2w1s1a1, w2indices, w1indices, s1indices, a1indices, k, verbose) fmt.Println(result1) result2 := mc.MorphologicalComputationMI2(w2w1s1a1, w2indices, w1indices, s1indices, a1indices, k, verbose) fmt.Println(result2) } |
MI_CA
where I(W’;W) and I(W’;A) use the KSG estimator for mutual information on continuous data.
Using the gomi binary
To calculate MI_CA with the binary, use the following command line parameters:
1 |
gomi -mi MI_CA -file musfib.csv -wi 1,2,3 -ai 9 -v -c -cm 2 -o MI_CA.csv |
The file musfib was used in [1] and can be downloaded [here].
Explanation of the command line options used in the example above:
-mi MI_CA | Chooses MI_CA as the measure |
-file musfib.csv | Data is provided in the file musfib.csv |
-wi 1,2,3 | Columns 1,2,3 of the data provided in musfib.csv define the world state (counting starts with 0) |
-ai 9 | Column 9 of the data provided in musfib.csv defines the action state (counting starts with 0) |
-v | gomi will print useful information while it is running and it will print the result |
-c | gomi will use the KSG Estimator for mutual information. |
-cm 2 | gomi will use the KSG Estimator 2 for mutual information. KSG 1 estimator can be chosen with -cm 1 |
-o MI_CA.csv | The result and the specified parameters will be written to MI_CA.csv |
The full list of command line options is given below.
Using gomi as a library
The measures implemented in gomi can also be used as a library. The following code snippet gives an example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
package main import ( "fmt" "math/rand" goent "github.com/kzahedi/goent/continuous" mc "github.com/kzahedi/gomi/continuous" ) func main() { // W and A are just examples for data. These would usually be read from some data file // For this example to work, we provide some dummy data wDim := 2 w := make([][]float64, 1000, 1000) for i := 0; i < 1000; i++ { w[i] = make([]float64, wDim, wDim) w[i][0] = rand.Float64() w[i][1] = rand.Float64() } aDim := 3 a := make([][]float64, 1000, 1000) for i := 0; i < 1000; i++ { a[i] = make([]float64, aDim, aDim) a[i][0] = rand.Float64() a[i][1] = rand.Float64() a[i][2] = rand.Float64() } // creating w', w, a data w2w1a1 := make([][]float64, 999, 999) for i := 0; i < len(w)-1; i++ { w2w1a1[i] = make([]float64, 2*wDim+aDim, 2*wDim+aDim) // w' w2w1a1[i][0] = w[i+1][0] w2w1a1[i][1] = w[i+1][1] // w w2w1a1[i][2] = w[i][0] w2w1a1[i][3] = w[i][1] // a w2w1a1[i][4] = a[i][0] w2w1a1[i][5] = a[i][1] w2w1a1[i][6] = a[i][2] } w2w1a1 = goent.Normalise(w2w1a1, false) // calculating MI_CA w2indices := []int{0, 1} w1indices := []int{2, 3} a1indices := []int{4, 5, 6} k := 30 verbose := true result1 := mc.MorphologicalComputationCA1(w2w1a1, w2indices, w1indices, a1indices, k, verbose) fmt.Println(result1) result2 := mc.MorphologicalComputationCA2(w2w1a1, w2indices, w1indices, a1indices, k, verbose) fmt.Println(result2) } |
MI_WA
where I(W’;W,A) and I(W’;A) use the KSG estimator for mutual information on continuous data.
Using the gomi binary
To calculate MI_WA with the binary, use the following command line parameters:
1 |
gomi -mi MI_WA -file musfib.csv -wi 1,2,3 -ai 9 -v -c -cm 2 -o MI_WA.csv |
The file musfib was used in [1] and can be downloaded [here].
Explanation of the command line options used in the example above:
-mi MI_CA | Chooses MI_CA as the measure |
-file musfib.csv | Data is provided in the file musfib.csv |
-wi 1,2,3 | Columns 1,2,3 of the data provided in musfib.csv define the world state (counting starts with 0) |
-ai 9 | Column 9 of the data provided in musfib.csv defines the action state (counting starts with 0) |
-v | gomi will print useful information while it is running and it will print the result |
-c | gomi will use the KSG Estimator for mutual information. |
-cm 2 | gomi will use the KSG Estimator 2 for mutual information. KSG 1 estimator can be chosen with -cm 1 |
-o MI_CA.csv | The result and the specified parameters will be written to MI_CA.csv |
The full list of command line options is given below.
Using gomi as a library
The measures implemented in gomi can also be used as a library. The following code snippet gives an example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
package main import ( "fmt" "math/rand" goent "github.com/kzahedi/goent/continuous" mc "github.com/kzahedi/gomi/continuous" ) func main() { // W and A are just examples for data. These would usually be read from some data file // For this example to work, we provide some dummy data wDim := 2 w := make([][]float64, 1000, 1000) for i := 0; i < 1000; i++ { w[i] = make([]float64, wDim, wDim) w[i][0] = rand.Float64() w[i][1] = rand.Float64() } aDim := 3 a := make([][]float64, 1000, 1000) for i := 0; i < 1000; i++ { a[i] = make([]float64, aDim, aDim) a[i][0] = rand.Float64() a[i][1] = rand.Float64() a[i][2] = rand.Float64() } // creating w', w, a data w2w1a1 := make([][]float64, 999, 999) for i := 0; i < len(w)-1; i++ { w2w1a1[i] = make([]float64, 2*wDim+aDim, 2*wDim+aDim) // w' w2w1a1[i][0] = w[i+1][0] w2w1a1[i][1] = w[i+1][1] // w w2w1a1[i][2] = w[i][0] w2w1a1[i][3] = w[i][1] // a w2w1a1[i][4] = a[i][0] w2w1a1[i][5] = a[i][1] w2w1a1[i][6] = a[i][2] } w2w1a1 = goent.Normalise(w2w1a1, false) // calculating MI_WA w2indices := []int{0, 1} w1indices := []int{2, 3} a1indices := []int{4, 5, 6} k := 30 verbose := true result1 := mc.MorphologicalComputationWA1(w2w1a1, w2indices, w1indices, a1indices, k, verbose) fmt.Println(result1) result2 := mc.MorphologicalComputationWA2(w2w1a1, w2indices, w1indices, a1indices, k, verbose) fmt.Println(result2) } |
MI_WS
where I(W’;W,S) and I(W’;S) use the KSG estimator for mutual information on continuous data.
Using the gomi binary
To calculate MI_WS with the binary, use the following command line parameters:
1 |
gomi -mi MI_WS -file musfib.csv -wi 1,2,3 -ai 9 -v -c -cm 2 -o MI_WS.csv |
The file musfib was used in [1] and can be downloaded [here].
Explanation of the command line options used in the example above:
-mi MI_WS | Chooses MI_WS as the measure |
-file musfib.csv | Data is provided in the file musfib.csv |
-wi 1,2,3 | Columns 1,2,3 of the data provided in musfib.csv define the world state (counting starts with 0) |
-ai 9 | Column 9 of the data provided in musfib.csv defines the action state (counting starts with 0) |
-v | gomi will print useful information while it is running and it will print the result |
-c | gomi will use the KSG Estimator for mutual information. |
-cm 2 | gomi will use the KSG Estimator 2 for mutual information. KSG 1 estimator can be chosen with -cm 1 |
-o MI_WS.csv | The result and the specified parameters will be written to MI_WS.csv |
The full list of command line options is given below.
Using gomi as a library
The measures implemented in gomi can also be used as a library. The following code snippet gives an example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
package main import ( "fmt" "math/rand" goent "github.com/kzahedi/goent/continuous" mc "github.com/kzahedi/gomi/continuous" ) func main() { // W and A are just examples for data. These would usually be read from some data file // For this example to work, we provide some dummy data wDim := 2 w := make([][]float64, 1000, 1000) for i := 0; i < 1000; i++ { w[i] = make([]float64, wDim, wDim) w[i][0] = rand.Float64() w[i][1] = rand.Float64() } sDim := 3 s := make([][]float64, 1000, 1000) for i := 0; i < 1000; i++ { s[i] = make([]float64, sDim, sDim) s[i][0] = rand.Float64() s[i][1] = rand.Float64() s[i][2] = rand.Float64() } // creating w', w, a data w2w1s1 := make([][]float64, 999, 999) for i := 0; i < len(w)-1; i++ { w2w1s1[i] = make([]float64, 2*wDim+sDim, 2*wDim+sDim) // w' w2w1s1[i][0] = w[i+1][0] w2w1s1[i][1] = w[i+1][1] // w w2w1s1[i][2] = w[i][0] w2w1s1[i][3] = w[i][1] // a w2w1s1[i][4] = s[i][0] w2w1s1[i][5] = s[i][1] w2w1s1[i][6] = s[i][2] } w2w1s1 = goent.Normalise(w2w1s1, false) // calculating MI_WS w2indices := []int{0, 1} w1indices := []int{2, 3} s1indices := []int{4, 5, 6} k := 30 verbose := true result1 := mc.MorphologicalComputationWS1(w2w1s1, w2indices, w1indices, s1indices, k, verbose) fmt.Println(result1) result2 := mc.MorphologicalComputationWS2(w2w1s1, w2indices, w1indices, s1indices, k, verbose) fmt.Println(result2) } |
Command line parameters
Option | Explanation |
---|---|
-help | Will show command line parameters with explantions. |
-v | Verbose. If not provided, gomi will be executed silently. |
-mi | String identifier for the morphological intelligence quantification. One example is MI_W. For a full list, please use the help command line option. |
-c | The discrete (frequency based) estimators are used by default. If this options is provided, the estimators on continuous data (KSG Estimator and Frenzel-Pompe) are used instead. |
-cm | Continuous mode. There are two different KSG Estimators for mutual information. For those continuous morphological intelligence quantification which operate with mutual information, the KSG Estimator can be chosen with this command line options. Possible values are 1 and 2. |
-s | State-dependent results. By default, the averaged results are provided. If this option is given, the results are calculated for each state, i.e., the result is a vector with a value for each row in the original dataset. |
-bins | This option is used only for the discrete estimators. It determines the number of bins for each column of the W, S, and A datasets. |
-i | Iteration. This command line option is only used for MI_SY, MI_Wp, and MI_SY_NID. It determines the number of iterations for the iterative scaling algorithm. |
-o | Output file. The default value is "out.csv". gomi writes all results to the output file, including a header section that includes the full parameterisation of the calculation. |
-wbins | Only used for discrete measures. In case the world state is given by more than one column in the dataset, this option allows to set the binning for each column. |
-abins | Only used for discrete measures. In case the action state is given by more than one column in the dataset, this option allows to set the binning for each column. |
-sbins | Only used for discrete measures. In case the sensor state is given by more than one column in the dataset, this option allows to set the binning for each column. |
-file | This option should be used if W, S, A are provided in a single file. The columns for W, S, and A are the specified with the -wi, -si, and -ai options (see below). |
-wi | The values here specify the column of the file provided with -file that relate to the world state. |
-ai | The values here specify the column of the file provided with -file that relate to the action state. |
-si | The values here specify the column of the file provided with -file that relate to the sensor state. |
-wfile | World state file. All columns of this file will be considered in the calculations. |
-afile | Action state file. All columns of this file will be considered in the calculations. |
-sfile | Sensor state file. All columns of this file will be considered in the calculations. |
-dfile | Domain file. This option will only be used for discrete measures. During discretisation, each column is normalised. For comparability between different files, a domain file can be specified, which provides the minimum and maximum values for the world state, action state, and sensor state data. |
-k | This parameter is only used for continuous estimators. It is the parameter used for the k-nearest neighbour estimation of entropies. |
-log | If this parameter is provided, gomi will write a JSON file that included all information with respect to calculation, including the full raw and pre-processed data |
Configuration Files
Domain File
1 2 3 4 5 6 |
W min: [-0.1, -0.2, -0.3] W max: [0.1, 0.2, 0.3] S min: [-1.1, -1.2, -1.3, -1.4] S max: [1.1, 1.2, 1.3, 1.4] A min: [-2.1, -2.2, -2.3, -2.4, -2.5] A max: [2.1, 2.2, 2.3, 2.4, 2.5] |
Configuration File
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
W min: [-0.1, -0.2, -0.3] Measure: MI_W Continuous: true Continuous mode: 1 State-dependent: true Verbose: true Bins: 300 Iterations: 1000 k: 100 Output file: out.csv W Bins: A Bins: S Bins: W Indices: 1,2,3 A Indices: 9 S Indices: 4 Full data file: /Users/zahedi/projects/entropy/experiments/hopping/data/musfib.csv W data file: A data file: S data file: Domain file: |
Bibliography
[Bibtex]
@article{Ghazi-Zahedi2016aEvaluating,
Author = {Ghazi-Zahedi, Keyan and Haeufle, Daniel F.B. and Montufar, Guido Francisco and Schmitt, Syn and Ay, Nihat},
Issn = {2296-9144},
Journal = {Frontiers in Robotics and AI},
Number = {42},
Pdf = {http://www.frontiersin.org/computational_intelligence/10.3389/frobt.2016.00042/abstract},
Title = {Evaluating Morphological Computation in Muscle and DC-motor Driven Models of Hopping Movements},
Volume = {3},
Year = {2016}}