FAQ: Simulating a Binomial Test - Calculating a One-Sided P-Value

This community-built FAQ covers the "Calculating a One-Sided P-Value " exercise from the lesson “Simulating a Binomial Test”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Master Statistics with Python

FAQs on the exercise _Calculating a One-Sided P-Value _

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!
You can also find further discussion and get answers to your questions over in Language Help.

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head to Language Help and Tips and Resources. If you are wanting feedback or inspiration for a project, check out Projects.

Looking for motivation to keep learning? Join our wider discussions in Community

Learn more about how to use this guide.

Found a bug? Report it online, or post in Bug Reporting

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

import numpy as np
outcomes = np.array(outcomes)
p_value = np.sum(outcomes <= 2)/len(outcomes)
print(p_value) #output: 0.059

why does outcomes have to be in an array?

In this lesson, it says that, to calculate the P-value for the Alternative hypothesis, calculate the proportion of values in null_outcomes that are equal to or less than 41.

I’m having a hard time understanding where this “41” comes from. Sure, the lesson gives easily understandable context, but I’m not confident that I would be able to apply the concept properly to a real-world scenario, since I’m having a hard time understanding how these “dots” connect.

I’m kinda having a question here too.

We want to calculate the probability of the visitors making purchases being less than 10% of the total visitors (Checkpoint 1).
Since the 10% in a 500 sample is 50, and since the Alternative Hypothesis is that the probability of a purchase rate was LESS THAN 10%, shouldn’t we need to test against “50” instead of “41”?

My question is: Why 41 and not 50.

Thanks a lot guys, if anyone has something to contribute on that, you 're welcome.

1 Like

Earlier in the lesson we were asked to calculate how many people bought an item in a particular month. Usually they expect 10% (50/500) but in this case we calculated 41 people bought an item. Is this a significant drop in sales or just a random instance? So in the one sided p-value test, we are calculating the probability of observing that value or less.

2 Likes