私下收集敏感調查回覆 ||數學∩編程
這是我正在寫的書中的一章草稿, 程式設計師實用數學:生產軟體中的數學之旅。 提示: 當調查受訪者不相信他們的回答會被保密時,確定有關敏感問題的總結統計數據。 解決方案: import random def respond_privately(true_answer: bool) -> bool: ”’Respond to a survey with plausible deniability about your answer.”’ be_honest = random.random() < 0.5 random_answer = random.random() < 0.5 return true_answer if be_honest else random_answer def aggregate_responses(responses: List(bool)) -> Tuple(float, float): ”’Return the estimated fraction of survey respondents that have a truthful…
