Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8827761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:26:56+00:00 2026-06-14T07:26:56+00:00

I thought I can make life a little easier in data statistics by making

  • 0

I thought I can make life a little easier in data statistics by making a small program which returns the results of sampling distribution of the mean (with standard error). It does this part successfully but in an attempt to return the z-score by using the formula I found here, it returns -1#IND. My interpretation of that formula is:

((1 / (sqrt(2 * pi) * stdev)) * pow(e, (normalpow))

where

double normalpow = -0.5 * ((mean - popmean) * (mean-popmean) / stdev)

I did a little more investigating and found that (mean - popmean) * (mean - popmean) was evaluating to 0 no matter what. How can I get around this problem of normalpow evaluating to 0.

#include <iostream>
#include <string>
#include <sstream>
#include <math.h>


using namespace std;

double number  ;
double mean ;
double popmean ;
double stdev ;
double square = 2;
double e = 2.71828182845904523536;
double pi = 3.14159265358979323846;
double normalpow = -0.5*((mean-popmean)*(mean-popmean)/stdev);
int main ()
{
    string continuer ;
    do
    {
        cout << "Enter Sample Mean: " << endl;
        cin >> mean;
        cout << "Enter Population Mean: " << endl;
        cin >> popmean;
        cout << "Enter Standard Deviation: " << endl;
        cin >> stdev;
        cout << "Enter Sample Size: " << endl;
        cin >> number;
        if (stdev == 0)
            cout << ((mean-popmean)/(number))<< endl;
        else
        {
            cout << ((mean-popmean)/((stdev)/(sqrt(number))))<< endl;
            cout << ((1/(sqrt(2*pi)*stdev))*pow(e, (normalpow)))<< endl;
        }
        cout << "If you want to continue, Press Y" << endl ;
        cin >> continuer;
    } while (continuer == "Y" || continuer == "y") ;
    return 0;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T07:26:58+00:00Added an answer on June 14, 2026 at 7:26 am
    using namespace std;
    
    double number  ;
    double mean ;
    double popmean ;
    double stdev ;
    double square = 2;
    double e = 2.71828182845904523536;
    double pi = 3.14159265358979323846;
    double normalpow = -0.5*((mean-popmean)*(mean-popmean)/stdev);
    

    These are all variables with static storage duration, so those without explicit initialisers are initialised to 0.

    Hence mean, popmean and stdev are all 0 when normalpow is initialised, and that initialisation results in

    double normalpow = -0.5*(0.0*0.0/0.0);
    

    which gives a NaN.

    You never change normalpow afterwards, so any computation involving it results in a NaN.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to build node.js in a debootstrap environment (which can be thought as
I wish to know is there any way in which I can make it
I have a multi-module project. I thought I can compile only a single module
I thought I have seen this somewhere but can't find it any more on
How can you add a click event to dynamically created menu item? I thought
I can't find anything definite using my favourite tool , however I thought I
How can I get the following test to pass with NHibernate? I thought it
How can we detect if a directed graph is cyclic? I thought using breadth
I thought it was alias for simple foreign key relation ,but seems not. Can
can anyone help, i have problem doing a sort, I thought i had it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.