
Single Proportion One-Line Test
Read It: Single Proportion One-Line Test
To conduct the one-line test for a single proportion hypothesis test, you will use a one sample binomial test. Below, we demonstrate how to implement this code.
Watch It: Video - Single Proportion OneLine Test (3:54 minutes)
Click here for a transcript.
Credit: © Penn State is licensed under CC BY-NC-SA 4.0(link is external)
Try It: Google Colab
- Click the Google Colab file used in the video here(link is external).
- Go to the Colab file and click "File" then "Save a copy in Drive", this will create a new Colab file that you can edit in your own Google Drive account.
- Once you have it saved in your Drive, ry to edit the following code to run the single proportion one-line test. Remember to import the libraries and run the code to create some data.
Note that you must be logged into your PSU Google Workspace in order to access the file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # Libraries import numpy as np import scipy.stats as stats # create some data x = np.random.randint( 0 , 100 , 1000 ) # initialize the variables success_rate = ... # success = the number of data points in x above 50 samp_size = ... # sample size = the total number of data points in x # implement one-line test results = ... results.pvalue |
Once you have implemented this code on your own, come back to this page to test your knowledge.