@@ -0,0 +1,2666 @@
+package training.MarkovChain;%0A%0Aimport analysis.harmonic.ChordDegree;%0Aimport javafx.util.Pair;%0A%0Aimport java.util.HashMap;%0A%0Apublic class MarkovDegree %7B%0A%0A    // Using two ChordDegree parameter instead of a Pair one because%0A    // Values cannot be changed in a Javafx pair ...%0A    // https://docs.oracle.com/javafx/2/api/javafx/util/Pair.html%0A    private ChordDegree depth2_;%0A    private ChordDegree depth1_;%0A    private HashMap%3CPair%3CChordDegree, ChordDegree%3E, HashMap%3CChordDegree, Integer%3E%3E transitions_;%0A%0A    /**%0A     * Constructor for the MarkovDegree class.%0A     * Takes no parameter so transition matrix should be%0A     */%0A    public MarkovDegree() %7B%0A        depth1_ = null;%0A        depth2_ = null;%0A        transitions_ = new HashMap%3C%3E();%0A    %7D%0A%0A    // ---------- PUBLIC FUNCTIONS ----------%0A%0A    /**%0A     * This function add a degree to fill the markov transition matrix.%0A     * @param chordDegree%0A     */%0A    public void addDegree(ChordDegree chordDegree) %7B%0A        Pair%3CChordDegree, ChordDegree%3E line = new Pair%3C%3E(depth2_, depth1_);%0A        addLineEntry(line, chordDegree);%0A        HashMap%3CChordDegree, Integer%3E column = transitions_.get(line);%0A        updateDepth(chordDegree);%0A    %7D%0A%0A    // --------- PRIVATE FUNCTIONS ----------%0A%0A    /**%0A     * This function add a new column in the Markov Transition Matrix when the given%0A     * ChordDegree doesn't match a key of the column. Otherwise, it increment the integer%0A     * value of the existing key.%0A     * @param column%0A     * @param key%0A     */%0A    private void addColumnEntry(HashMap%3CChordDegree, Integer%3E column, ChordDegree key) %7B%0A        if (column.get(key) == null)%0A            column.put(key, 1);%0A        else%0A            column.put(key, column.get(key) + 1);%0A    %7D%0A%0A    /**%0A     * This function add a new line in the Markov Transition matrix when%0A     * the combinaison of values of depth1_ and depth2_ is new.%0A     * @param lineKey%0A     * @param columnKey%0A     */%0A    private void addLineEntry(Pair%3CChordDegree, ChordDegree%3E lineKey, ChordDegree columnKey) %7B%0A        HashMap%3CChordDegree, Integer%3E column = transitions_.get(lineKey);%0A        if (column == null) %7B%0A            column = new HashMap%3C%3E();%0A            addColumnEntry(column, columnKey);%0A            transitions_.put(lineKey, column);%0A        %7D%0A        else%0A            addColumnEntry(column, columnKey);%0A    %7D%0A%0A    /**%0A     * This function update the depth the transition matrix by replacing%0A     * the depth2 value by the depth1 and the depth1 value by the newly added%0A     * ChordDegree.%0A     * @param chordDegree%0A     */%0A    private void updateDepth(ChordDegree chordDegree) %7B%0A        depth2_ = depth1_;%0A        depth1_ = depth2_;%0A    %7D%0A%7D%0A

add MarkovDegree class