Created
June 19, 2011 03:29
-
-
Save gfredericks/1033727 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn probability-of-taking-this-transition | |
[tid incoming-variations transitions payment-rule] | |
(let [this-trans | |
(first | |
(filter #(= tid (:id %)) transitions)), | |
this-variations (this-trans :variations), | |
this-feasibility (this-trans payment-rule), | |
change-points | |
(distinct | |
(for [feas (map payment-rule transitions), | |
:when #(or (nil? this-feasibility) (<= feas this-feasibility))] | |
(or feas :infinity)))] | |
(prn "CHANGE POINTS" change-points) | |
(zipmap | |
change-points | |
(for [change-point change-points] | |
(let [feasibles | |
(filter | |
(fn [tran] | |
(let [its-feasibility (tran payment-rule)] | |
(if (= :infinity change-point) | |
(nil? its-feasibility) | |
(or | |
(nil? its-feasibility) | |
(>= its-feasibility change-point))))) | |
transitions)] | |
(prn "FEASIBLES" change-point feasibles) | |
(if (some #{tid} (map :id feasibles)) | |
; This line is the crux of the bug I think | |
; maybe we should multiply by the incoming variations?? | |
; (/ this-variations (apply + (map :variations feasibles)))))))) | |
; (/ 1 (apply + (map :variations feasibles)))))))) | |
(/ incoming-variations (apply + (map :variations feasibles))) | |
0)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment