INNER CODE UNIT · Python

like_insta_post

tuangauss/DataScienceProjects · Python/lincoln_estimate.py:3

def like_insta_post(p):
    "Find an error with probability p"
    return 1 if random.random() < p else 0

def simulate(true_audience, p1, p2, reps=10000):
    """Simulate Lincoln's method for estimating errors
    given the true number of errors, each person's probability
    of finding an error, and the number of simulations to run."""
    naive_estimates = []
    lincoln_estimates = []
    
    for rep in range(reps):
        like_post_1 = np.array([like_insta_post(p1) for _ in range(true_audience)])
        like_post_2 = np.array([like_insta_post(p2) for _ in range(true_audience)])
        like_post1_count = sum(like_post_1)
        like_post2_count = sum(like_post_2)
        overlap = np.sum(like_post_1 & like_post_2)
        

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…