I wrote the following program shown below that produces a normally distributed random number several times, and then takes the average of them. The problem that I have been having though is that the output it has been producing is 0.0288385 despite the fact that I set the mean of the normal distribution to be 0.1. Does anybody know why this output value would be so far off from 0.1 despite having averaged over such a large number of random numbers namely 10,000 of them? Also does anyone know how to randomly seed this random number generator such that it gives a different value each time its run perhaps by seeding it with the windows timer? Below is the program.
#include <iostream>
#include <chrono>
#include <random>
int main()
{
std::default_random_engine generator( std::random_device{}() ) ;
// or, if we do not have a true std::random_device:
// const auto seed = std::chrono::high_resolution_clock::now().time_since_epoch().count() ;
// std::default_random_engine generator(seed) ;
std::normal_distribution<double> distribution1(0.1,3.0);
constint n = 1000000 ;
double sum = 0 ;
for( int i = 0 ; i < n ; ++i ) sum += distribution1(generator) ;
std::cout << sum / n << '\n' ;
}