
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
C++ Program to implement standard error of mean
In this tutorial, we will be discussing a program to implement standard error of mean.
Standard error of mean is the estimation of sample mean dispersion from population mean. Then it is used to estimate the approximate confidence intervals for the mean.
Example
#include <bits/stdc++.h> using namespace std; //calculating sample mean float calc_mean(float arr[], int n){ float sum = 0; for (int i = 0; i < n; i++) sum = sum + arr[i]; return sum / n; } //calculating standard deviation float calc_deviation(float arr[], int n){ float sum = 0; for (int i = 0; i < n; i++) sum = sum + (arr[i] - calc_mean(arr, n)) * (arr[i] - calc_mean(arr, n)); return sqrt(sum / (n - 1)); } //calculating sample error float calc_error(float arr[], int n){ return calc_deviation(arr, n) / sqrt(n); } int main(){ float arr[] = { 78.53, 79.62, 80.25, 81.05, 83.21, 83.46 }; int n = sizeof(arr) / sizeof(arr[0]); cout << calc_error(arr, n) << endl; return 0; }
Output
0.8063
- Related Articles
- How to find the standard error of mean in R?
- How to calculate standard error of the mean in Excel?
- C++ program to implement standard deviation of grouped data
- What is C++ Standard Error Stream (cerr)?
- Getting the Standard Output and Standard Error Output Stream through Console in C#
- C++ Program to Calculate Standard Deviation
- C program to calculate the standard deviation
- C++ Program to Implement Vector
- C++ Program to Implement Treap
- C++ Program to Implement Trie
- C++ Program to Implement Dequeue
- C++ Program to Implement Queue
- C++ Program to Implement Stack
- C# program to implement FizzBuzz
- C program to implement CHECKSUM

Advertisements