Effacer les filtres
Effacer les filtres

Does normpdf() take z values?

3 vues (au cours des 30 derniers jours)
Shawn Simon
Shawn Simon le 3 Mai 2016
I am asking this because I have created a program in which a user inputs a some data, then inputs either a z value or an x value and the output is the probability . If the elements within the input data is less than 30, then the program uses the std() function for standard deviation. However, if the data exceeds 30 elements, then the program finds the population standard deviation, and uses that for sigma.
If the user inputs an x value, this is easy in that I can just use the given x, mu and respective sigma for the normpdf() calculation. However, if the user inputs a z value, I am not sure if I should use mu = 0 and sigma = 1 in normpdf(), or if I should change the z value to an x value, then use the respective mu and sigma values.

Réponse acceptée

Star Strider
Star Strider le 3 Mai 2016
The z-statistic normalises the data to have a mean of 0 and a standard deviation of 1, so using this syntax (from the documenation):
  • Y = normpdf(X) uses the standard normal distribution (mu = 0, sigma = 1).
So here ‘X’ would be the z-statistic.
You will probably have to test for the number of inputs to your function (using nargin) and then have your function determine how to deal with the data it receives. For example if it receives only one input, it would interpret that as a z-statistic, if separate mu and sigma you would have to use other function syntax calls to normpdf.
So it seems normpdf can do everything you want. You just have to determine how to call it in your function.

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by