<commit_before>
namespace measure::d_privacy {

template<typename eT>
bool is_private(const Chan<eT>& C, Metric<eT, uint> d) {

	return metric::is_lipschitz<eT,uint,Prob<eT>>(
		[&](uint x) -> Prob<eT> { return C.row(x); },
		d,
		metric::mult_total_variation<eT, Prob<eT>>(),
		range<uint>(0, C.n_rows)
	);
}

template<typename eT>
eT smallest_epsilon(const Chan<eT>& C, Metric<eT, uint> d) {

	return metric::lipschitz_constant<eT,uint,Prob<eT>>(
		[&](uint x) -> Prob<eT> { return C.row(x); },
		d,
		metric::mult_total_variation<eT, Prob<eT>>(),
		range<uint>(0, C.n_rows)
	);
}

template<typename eT>
eT d_vulnerability(Metric<eT, uint> d, const Prob<eT>& pi) {

	eT res(0);
	for(uint i = 0; i < pi.n_cols; i++) {
		for(uint j = i+1; j < pi.n_cols; j++) {
			// chainable elements are redundant to check
			// if(d.chainable(i, j)) continue;

			eT ratio = std::abs(std::log(pi(i)) - std::log(pi(j))) / d(i, j);
			if(less_than(res, ratio))
				res = ratio;<commit_msg>d_privacy: rename d_vulnerability -> prior<commit_after>
namespace measure::d_privacy {

template<typename eT>
bool is_private(const Chan<eT>& C, Metric<eT, uint> d) {

	return metric::is_lipschitz<eT,uint,Prob<eT>>(
		[&](uint x) -> Prob<eT> { return C.row(x); },
		d,
		metric::mult_total_variation<eT, Prob<eT>>(),
		range<uint>(0, C.n_rows)
	);
}

template<typename eT>
eT smallest_epsilon(const Chan<eT>& C, Metric<eT, uint> d) {

	return metric::lipschitz_constant<eT,uint,Prob<eT>>(
		[&](uint x) -> Prob<eT> { return C.row(x); },
		d,
		metric::mult_total_variation<eT, Prob<eT>>(),
		range<uint>(0, C.n_rows)
	);
}

// This is the "d-vulnerability" function, who's max-case capacity coincides with the smallest epsilon of d-privacy
//
template<typename eT>
eT prior(const Prob<eT>& pi, Metric<eT, uint> d) {

	eT res(0);
	for(uint i = 0; i < pi.n_cols; i++) {
		for(uint j = i+1; j < pi.n_cols; j++) {
			// chainable elements are redundant to check
			// if(d.chainable(i, j)) continue;

			eT ratio = std::abs(std::log(pi(i)) - std::log(pi(j))) / d(i, j);
			if(less_than(res, ratio))
				res = ratio;
{'fraction_non_alphanumeric': 0.1955896452540748, 'fraction_numerical': 0.004793863854266539, 'mean_word_length': 4.521164021164021, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 50, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3940567', 'n_tokens_mistral': 971, 'n_tokens_neox': 890, 'n_words': 191}