# How to do a OneSampleZTest for the proportion instead of the mean?

**URL:** <https://discourse.julialang.org/t/how-to-do-a-onesampleztest-for-the-proportion-instead-of-the-mean/85779>\
**Category:** Statistics\
**Tags:** question, package, hypothesis-tests\
**Created:** [August 15, 2022, 2:13pm UTC](https://discourse.julialang.org/t/how-to-do-a-onesampleztest-for-the-proportion-instead-of-the-mean/85779 "2022-08-15T14:13:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![floxo115](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/floxo115/32/38084_2.png) [@floxo115](https://discourse.julialang.org/u/floxo115)\
**Post date:** [August 15, 2022, 2:13pm UTC](https://discourse.julialang.org/t/how-to-do-a-onesampleztest-for-the-proportion-instead-of-the-mean/85779/1 "2022-08-15T14:13:31Z")

</div>

I am playing around with the HypothesisTests package and wanted to do a OneSampleZTest but with the population proportion instead of the populatin mean as the parameter of interest. But I really don’t find anyting in the documentation that tells me how to do it.

[link to docs](https://juliastats.org/HypothesisTests.jl/stable/parametric/#HypothesisTests.OneSampleZTest)

Maybe somebody can show me how to to it?

---

<div class="post-metadata">

**Author:** ![bkamins](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bkamins/32/208538_2.png) [@bkamins](https://discourse.julialang.org/u/bkamins)\
**Post date:** [August 22, 2022, 10:40am UTC](https://discourse.julialang.org/t/how-to-do-a-onesampleztest-for-the-proportion-instead-of-the-mean/85779/2 "2022-08-22T10:40:10Z")

</div>

There is no difference as proportion is mean of a sample from a binary variable.  
So if your proportion is `p` and sample size is `n` then:

```julia
OneSampleZTest(p, sqrt(p*(1-p)*n/(n-1)), n)

```
