proposition: Lemma EX_ord : `E X = \sum_(i < Nmax.+1) i%:R * PN i.
proof: Proof. rewrite /Ex (partition_big (inordf (size \o f)) (fun i => i \in 'I_Nmax.+1)) //=. apply : eq_bigr=> i _. rewrite /pr_eq; unlock. rewrite /Pr ffunE mulRC big_distrl /=. under eq_bigr do rewrite mulRC. apply: congr_big=>[//| x| x]; last by move/eqP<-; rewrite inordfE. rewrite inE; apply/eqP/eqP=> [<-|]. by rewrite inordfE /X/= INRE. rewrite /X /= -INRE => /INR_eq H. by apply: ord_inj; rewrite -H inordfE. Qed.
imports: mathcomp(all_ssreflect ssralg ssrnum matrix) Reals mathcomp(Rstruct) ssrR Reals_ext realType_ext logb ssr_ext ssralg_ext bigop_ext fdist proba entropy divergence log_sum source_code