:- multifile probabilistic_method/1. % probabilistic_method hookable :- ensure_loaded( library(lists) ). % sum_list/2, max_list/2, nth1/4 probabilistic_method( explicit(Rats,_Set,Rats) ). % probabilistic_method( explicit(Rats,Set,Rats) ) :- % length( Rats, LgtRats ), % length( Set, LgtSet ), % ( LgtRats =:= LgtSet -> % true % ; % write_error( fatal, ['Length mismatch in, explicit method', % set(LgtSet),against,rationals(LgtRats)'] ). % ). probabilistic_method( none([_Val],[1/1]) ). % special case, equivelant to uniform % designed as a default for pin/5 probabilistic_method( uniform(Set,Probs) ) :- length( Set, Nembers ), n_term_list( Nembers, 1/Nembers, Probs ). probabilistic_method( register(2) ) :- fail. probabilistic_method( finite_geometric(Factor,Set,Probs) ) :- length( Set, Nembers ), % Zeronembs is Nembers - 1, % method_finite_geometric_sum_denom( 0, Zeronembs, 0, Denom ), method_finite_geometric_nominators( 1, Nembers, Factor, Noms ), sum_list( Noms, Denom ), methods_integers_to_rationals( Noms, Denom, Probs ). % probabilistic_method( proximity(List,Pivot,List,Probs) ) :- probabilistic_method( proximity(List,Pivot,_Set,Probs) ) :- % Set is Singleton Var, % write( pivot_point(Pivot) ), nl, rationals_subtract_list_from( List, Pivot, Subtr ), rationals_abs_list( Subtr, Abstr ), rationals_add_list( Abstr, Sum ), rationals_subtract_list_from( Abstr, Sum, Diffs ), % % % rationals_invert_list( Abstr, Invert ), % % % rationals_to_probabilities( Invert, Probs ). % maplist( rationals_prob_compliment, Abstr,Comps ), % % rationals_to_probabilities( Comps, Probs ), % rationals_rev_proxb( Abstr, Probs ), % write( compliments(Comps) ), nl, % write_info( absolute, a(Abstr) ), % write_info( diffs, d(Diffs) ), % maplist( rationals_dilute, Abstr, Diluted, [1000000] ), % write( diluted(Diluted) ), nl, % rationals_to_probabilities( Diluted, Probs ), rationals_to_probabilities( Diffs, Probs ). % write_info( probabilities, p(Probs) ), % print_probs_n_vals( pr_order, Probs, Set ). :- ensure_loaded( 'methods/hypergeometric' ). probabilistic_method( hypergeometric([N1,N2],Set,Probs) ) :- length( Set, RPlus ), R is RPlus - 1, % pbc_method_hgeo_filter_elms( Set, N1P, 0/N1, 0/N2 ), % pbc_method_hgeo_filter_elms( Set, RP , 0/R , 0/_Q ), hypergeometric( N1, N2, R, Probs ). /* pbc_method_hgeo_filter_elms( [], _Functor, Fs/Fs, Fn/Fn ). pbc_method_hgeo_filter_elms( [H|T], Functor, Sat/Fs, Not/Fn ) :- Goal =.. [Functor,H], ( pfd_call_once( Goal ) -> NxSat is Sat + 1, NxNot is Not ; NxSat is Sat, NxNot is Not + 1 ), pbc_method_hgeo_filter_elms( T, Functor, NxSat/Fs, NxNot/Fn ). */