let do_measurement ~time =
let c_states, occurences = causal_states past_configurations pof_configurations in
let complexity_of_causalState =
Array.map (fun occ -> ~-. (log (float occ /. total_occurences))) occurences in
let complexity =
Femtolib.Array.fold_left2 (fun accu compl occ -> accu +. compl *. float occ)
0. complexity_of_causalState occurences
/. total_occurences in
let min_complexity = Array.fold_left min infinity complexity_of_causalState in
let max_complexity = Array.fold_left max neg_infinity complexity_of_causalState in
let color_of_cState =
let minc, maxc = match contrast_range with
| None ->
min_complexity,
(match max_complexity with 0. -> 1. | _ -> max_complexity)
| Some (minc, maxc) -> minc, maxc in
let range = max (maxc -. minc) min_float in
let colors = match contrast_range with
| None -> Array.map (fun compl -> Femtolib.Colors.gray ((maxc -. compl) /. range))
complexity_of_causalState
| Some _ -> Array.map
(fun compl -> (maxc -. compl) /. range |> max 0. |> min 1.
|> Femtolib.Colors.gray) complexity_of_causalState in
function -1 -> Graphics.red | c_state -> colors.(c_state) in
(fun time ->
Printf.printf "%6i %#8.3f %#8.3f %#8.3f\n%!" time min_complexity max_complexity complexity;
),
(fun time -> draw_cmplx color_of_cState c_states time)