kazuyamaa/multi-language-messages-01 huggingface dataset:
Task: Logical operations
C: if(myValue == 3 && myOtherValue == 5){
myResult = true;
}

C++: void print_logic(bool a, bool b)
{
  std::cout << std::boolalpha; 
  std::cout << "a and b is " << (a && b) << "\n";
  std::cout << "a or b is " << (a || b) << "\n";
  std::cout << "not a is " << (!a) << "\n";
}
Task: Logical operations
C: if(myValue == 3 && myOtherValue == 5){
myResult = true;
}

Go: func printLogic(a, b bool) {
    fmt.Println("a and b is", a && b)
    fmt.Println("a or b is", a || b)
    fmt.Println("not a is", !a)
}
Task: Logical operations
C: if(myValue == 3 && myOtherValue == 5){
myResult = true;
}

Java: boolean a = true;
boolean b = false;
System.Debug('a AND b: ' + (a && b));
System.Debug('a OR b: ' + (a || b));
System.Debug('NOT a: ' + (!a));
System.Debug('a XOR b: ' + (a ^ b));
Task: Logical operations
C: if(myValue == 3 && myOtherValue == 5){
myResult = true;
}

Python: def logic(a, b):
    print('a and b:', a and b)
    print('a or b:', a or b)
    print('not a:', not a)
Task: Logical operations
C: if(myValue == 3 && myOtherValue == 5){
myResult = true;
}

VB: Function Test(ByVal a As Boolean, ByVal b As Boolean)
    Console.WriteLine("And " & a And b)
    Console.WriteLine("Or " & a Or b)
    Console.WriteLine("Not " & Not a)
    Console.WriteLine("Xor " & a Xor b)
    Console.WriteLine("And, short-circuited " & a AndAlso b)
    Console.WriteLine("Or, short-circuited " & a OrElse b)
End Function
Task: Logical operations
C#: using System;

namespace LogicalOperations
{
    class Program
    {
        static void Main(string[] args)
        {
            bool a = true, b = false;
            Console.WriteLine("a and b is {0}", a && b);
            Console.WriteLine("a or b is {0}", a || b);
            Console.WriteLine("Not a is {0}", !a);
            Console.WriteLine("a exclusive-or b is {0}", a ^ b);
        }
    }
}

C++: void print_logic(bool a, bool b)
{
  std::cout << std::boolalpha; 
  std::cout << "a and b is " << (a && b) << "\n";
  std::cout << "a or b is " << (a || b) << "\n";
  std::cout << "not a is " << (!a) << "\n";
}
Task: Logical operations
C++: void print_logic(bool a, bool b)
{
  std::cout << std::boolalpha; 
  std::cout << "a and b is " << (a && b) << "\n";
  std::cout << "a or b is " << (a || b) << "\n";
  std::cout << "not a is " << (!a) << "\n";
}

Java: boolean a = true;
boolean b = false;
System.Debug('a AND b: ' + (a && b));
System.Debug('a OR b: ' + (a || b));
System.Debug('NOT a: ' + (!a));
System.Debug('a XOR b: ' + (a ^ b));
Task: Logical operations
C++: void print_logic(bool a, bool b)
{
  std::cout << std::boolalpha; 
  std::cout << "a and b is " << (a && b) << "\n";
  std::cout << "a or b is " << (a || b) << "\n";
  std::cout << "not a is " << (!a) << "\n";
}

VB: Function Test(ByVal a As Boolean, ByVal b As Boolean)
    Console.WriteLine("And " & a And b)
    Console.WriteLine("Or " & a Or b)
    Console.WriteLine("Not " & Not a)
    Console.WriteLine("Xor " & a Xor b)
    Console.WriteLine("And, short-circuited " & a AndAlso b)
    Console.WriteLine("Or, short-circuited " & a OrElse b)
End Function
Task: Logical operations
C#: using System;

namespace LogicalOperations
{
    class Program
    {
        static void Main(string[] args)
        {
            bool a = true, b = false;
            Console.WriteLine("a and b is {0}", a && b);
            Console.WriteLine("a or b is {0}", a || b);
            Console.WriteLine("Not a is {0}", !a);
            Console.WriteLine("a exclusive-or b is {0}", a ^ b);
        }
    }
}

Go: func printLogic(a, b bool) {
    fmt.Println("a and b is", a && b)
    fmt.Println("a or b is", a || b)
    fmt.Println("not a is", !a)
}
Task: Logical operations
C#: using System;

namespace LogicalOperations
{
    class Program
    {
        static void Main(string[] args)
        {
            bool a = true, b = false;
            Console.WriteLine("a and b is {0}", a && b);
            Console.WriteLine("a or b is {0}", a || b);
            Console.WriteLine("Not a is {0}", !a);
            Console.WriteLine("a exclusive-or b is {0}", a ^ b);
        }
    }
}

Java: boolean a = true;
boolean b = false;
System.Debug('a AND b: ' + (a && b));
System.Debug('a OR b: ' + (a || b));
System.Debug('NOT a: ' + (!a));
System.Debug('a XOR b: ' + (a ^ b));
Task: Logical operations
C#: using System;

namespace LogicalOperations
{
    class Program
    {
        static void Main(string[] args)
        {
            bool a = true, b = false;
            Console.WriteLine("a and b is {0}", a && b);
            Console.WriteLine("a or b is {0}", a || b);
            Console.WriteLine("Not a is {0}", !a);
            Console.WriteLine("a exclusive-or b is {0}", a ^ b);
        }
    }
}

Python: def logic(a, b):
    print('a and b:', a and b)
    print('a or b:', a or b)
    print('not a:', not a)
Task: Logical operations
C#: using System;

namespace LogicalOperations
{
    class Program
    {
        static void Main(string[] args)
        {
            bool a = true, b = false;
            Console.WriteLine("a and b is {0}", a && b);
            Console.WriteLine("a or b is {0}", a || b);
            Console.WriteLine("Not a is {0}", !a);
            Console.WriteLine("a exclusive-or b is {0}", a ^ b);
        }
    }
}

VB: Function Test(ByVal a As Boolean, ByVal b As Boolean)
    Console.WriteLine("And " & a And b)
    Console.WriteLine("Or " & a Or b)
    Console.WriteLine("Not " & Not a)
    Console.WriteLine("Xor " & a Xor b)
    Console.WriteLine("And, short-circuited " & a AndAlso b)
    Console.WriteLine("Or, short-circuited " & a OrElse b)
End Function
Task: Logical operations
Go: func printLogic(a, b bool) {
    fmt.Println("a and b is", a && b)
    fmt.Println("a or b is", a || b)
    fmt.Println("not a is", !a)
}

Java: boolean a = true;
boolean b = false;
System.Debug('a AND b: ' + (a && b));
System.Debug('a OR b: ' + (a || b));
System.Debug('NOT a: ' + (!a));
System.Debug('a XOR b: ' + (a ^ b));
Task: Logical operations
Go: func printLogic(a, b bool) {
    fmt.Println("a and b is", a && b)
    fmt.Println("a or b is", a || b)
    fmt.Println("not a is", !a)
}

Python: def logic(a, b):
    print('a and b:', a and b)
    print('a or b:', a or b)
    print('not a:', not a)
Task: Logical operations
Go: func printLogic(a, b bool) {
    fmt.Println("a and b is", a && b)
    fmt.Println("a or b is", a || b)
    fmt.Println("not a is", !a)
}

VB: Function Test(ByVal a As Boolean, ByVal b As Boolean)
    Console.WriteLine("And " & a And b)
    Console.WriteLine("Or " & a Or b)
    Console.WriteLine("Not " & Not a)
    Console.WriteLine("Xor " & a Xor b)
    Console.WriteLine("And, short-circuited " & a AndAlso b)
    Console.WriteLine("Or, short-circuited " & a OrElse b)
End Function
Task: Logical operations
Python: def logic(a, b):
    print('a and b:', a and b)
    print('a or b:', a or b)
    print('not a:', not a)

VB: Function Test(ByVal a As Boolean, ByVal b As Boolean)
    Console.WriteLine("And " & a And b)
    Console.WriteLine("Or " & a Or b)
    Console.WriteLine("Not " & Not a)
    Console.WriteLine("Xor " & a Xor b)
    Console.WriteLine("And, short-circuited " & a AndAlso b)
    Console.WriteLine("Or, short-circuited " & a OrElse b)
End Function
Task: Logical operations
C++: void print_logic(bool a, bool b)
{
  std::cout << std::boolalpha; 
  std::cout << "a and b is " << (a && b) << "\n";
  std::cout << "a or b is " << (a || b) << "\n";
  std::cout << "not a is " << (!a) << "\n";
}

Python: def logic(a, b):
    print('a and b:', a and b)
    print('a or b:', a or b)
    print('not a:', not a)
Task: Logical operations
Java: boolean a = true;
boolean b = false;
System.Debug('a AND b: ' + (a && b));
System.Debug('a OR b: ' + (a || b));
System.Debug('NOT a: ' + (!a));
System.Debug('a XOR b: ' + (a ^ b));

Python: def logic(a, b):
    print('a and b:', a and b)
    print('a or b:', a or b)
    print('not a:', not a)
Task: Logical operations
C++: void print_logic(bool a, bool b)
{
  std::cout << std::boolalpha; 
  std::cout << "a and b is " << (a && b) << "\n";
  std::cout << "a or b is " << (a || b) << "\n";
  std::cout << "not a is " << (!a) << "\n";
}

Go: func printLogic(a, b bool) {
    fmt.Println("a and b is", a && b)
    fmt.Println("a or b is", a || b)
    fmt.Println("not a is", !a)
}
Task: Logical operations
Java: boolean a = true;
boolean b = false;
System.Debug('a AND b: ' + (a && b));
System.Debug('a OR b: ' + (a || b));
System.Debug('NOT a: ' + (!a));
System.Debug('a XOR b: ' + (a ^ b));

VB: Function Test(ByVal a As Boolean, ByVal b As Boolean)
    Console.WriteLine("And " & a And b)
    Console.WriteLine("Or " & a Or b)
    Console.WriteLine("Not " & Not a)
    Console.WriteLine("Xor " & a Xor b)
    Console.WriteLine("And, short-circuited " & a AndAlso b)
    Console.WriteLine("Or, short-circuited " & a OrElse b)
End Function
Task: Logical operations
C: if(myValue == 3 && myOtherValue == 5){
myResult = true;
}

PHP: function print_logic($a, $b)
{
    echo "a and b is ", $a && $b ? 'True' : 'False', "\n";
    echo "a or b is ", $a || $b ? 'True' : 'False', "\n";
    echo "not a is ", ! $a ? 'True' : 'False', "\n";
}
Task: Logical operations
C#: using System;

namespace LogicalOperations
{
    class Program
    {
        static void Main(string[] args)
        {
            bool a = true, b = false;
            Console.WriteLine("a and b is {0}", a && b);
            Console.WriteLine("a or b is {0}", a || b);
            Console.WriteLine("Not a is {0}", !a);
            Console.WriteLine("a exclusive-or b is {0}", a ^ b);
        }
    }
}

PHP: function print_logic($a, $b)
{
    echo "a and b is ", $a && $b ? 'True' : 'False', "\n";
    echo "a or b is ", $a || $b ? 'True' : 'False', "\n";
    echo "not a is ", ! $a ? 'True' : 'False', "\n";
}
Task: Logical operations
C++: void print_logic(bool a, bool b)
{
  std::cout << std::boolalpha; 
  std::cout << "a and b is " << (a && b) << "\n";
  std::cout << "a or b is " << (a || b) << "\n";
  std::cout << "not a is " << (!a) << "\n";
}

PHP: function print_logic($a, $b)
{
    echo "a and b is ", $a && $b ? 'True' : 'False', "\n";
    echo "a or b is ", $a || $b ? 'True' : 'False', "\n";
    echo "not a is ", ! $a ? 'True' : 'False', "\n";
}
Task: Logical operations
Go: func printLogic(a, b bool) {
    fmt.Println("a and b is", a && b)
    fmt.Println("a or b is", a || b)
    fmt.Println("not a is", !a)
}

PHP: function print_logic($a, $b)
{
    echo "a and b is ", $a && $b ? 'True' : 'False', "\n";
    echo "a or b is ", $a || $b ? 'True' : 'False', "\n";
    echo "not a is ", ! $a ? 'True' : 'False', "\n";
}
Task: Logical operations
Java: boolean a = true;
boolean b = false;
System.Debug('a AND b: ' + (a && b));
System.Debug('a OR b: ' + (a || b));
System.Debug('NOT a: ' + (!a));
System.Debug('a XOR b: ' + (a ^ b));

PHP: function print_logic($a, $b)
{
    echo "a and b is ", $a && $b ? 'True' : 'False', "\n";
    echo "a or b is ", $a || $b ? 'True' : 'False', "\n";
    echo "not a is ", ! $a ? 'True' : 'False', "\n";
}
Task: Logical operations
Python: def logic(a, b):
    print('a and b:', a and b)
    print('a or b:', a or b)
    print('not a:', not a)

PHP: function print_logic($a, $b)
{
    echo "a and b is ", $a && $b ? 'True' : 'False', "\n";
    echo "a or b is ", $a || $b ? 'True' : 'False', "\n";
    echo "not a is ", ! $a ? 'True' : 'False', "\n";
}
Task: Logical operations
VB: Function Test(ByVal a As Boolean, ByVal b As Boolean)
    Console.WriteLine("And " & a And b)
    Console.WriteLine("Or " & a Or b)
    Console.WriteLine("Not " & Not a)
    Console.WriteLine("Xor " & a Xor b)
    Console.WriteLine("And, short-circuited " & a AndAlso b)
    Console.WriteLine("Or, short-circuited " & a OrElse b)
End Function

PHP: function print_logic($a, $b)
{
    echo "a and b is ", $a && $b ? 'True' : 'False', "\n";
    echo "a or b is ", $a || $b ? 'True' : 'False', "\n";
    echo "not a is ", ! $a ? 'True' : 'False', "\n";
}
Task: Statistics_Normal distribution
C: 
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <time.h>


#define NMAX 10000000


double mean(double* values, int n)
{
    int i;
    double s = 0;

    for ( i = 0; i < n; i++ )
        s += values[i];
    return s / n;
}


double stddev(double* values, int n)
{
    int i;
    double average = mean(values,n);
    double s = 0;

    for ( i = 0; i < n; i++ )
        s += (values[i] - average) * (values[i] - average);
    return sqrt(s / (n - 1));
}


double* generate(int n)
{
    int i;
    int m = n + n % 2;
    double* values = (double*)calloc(m,sizeof(double));
    double average, deviation;

    if ( values )
    {
        for ( i = 0; i < m; i += 2 )
        {
            double x,y,rsq,f;
            do {
                x = 2.0 * rand() / (double)RAND_MAX - 1.0;
                y = 2.0 * rand() / (double)RAND_MAX - 1.0;
                rsq = x * x + y * y;
            }while( rsq >= 1. || rsq == 0. );
            f = sqrt( -2.0 * log(rsq) / rsq );
            values[i]   = x * f;
            values[i+1] = y * f;
        }
    }
    return values;
}


void printHistogram(double* values, int n)
{
    const int width = 50;    
    int max = 0;

    const double low   = -3.05;
    const double high  =  3.05;
    const double delta =  0.1;

    int i,j,k;
    int nbins = (int)((high - low) / delta);
    int* bins = (int*)calloc(nbins,sizeof(int));
    if ( bins != NULL )
    {
        for ( i = 0; i < n; i++ )
        {
            int j = (int)( (values[i] - low) / delta );
            if ( 0 <= j  &&  j < nbins )
                bins[j]++;
        }

        for ( j = 0; j < nbins; j++ )
            if ( max < bins[j] )
                max = bins[j];

        for ( j = 0; j < nbins; j++ )
        {
            printf("(%5.2f, %5.2f) |", low + j * delta, low + (j + 1) * delta );
            k = (int)( (double)width * (double)bins[j] / (double)max );
            while(k-- > 0) putchar('*');
            printf("  %-.1f%%", bins[j] * 100.0 / (double)n);
            putchar('\n');
        }

        free(bins);
    }
}


int main(void)
{
    double* seq;

    srand((unsigned int)time(NULL));

    if ( (seq = generate(NMAX)) != NULL )
    {
        printf("mean = %g, stddev = %g\n\n", mean(seq,NMAX), stddev(seq,NMAX));
        printHistogram(seq,NMAX);
        free(seq);

        printf("\n%s\n", "press enter");
        getchar();
        return EXIT_SUCCESS;
    }
    return EXIT_FAILURE;
}

Python: from __future__ import division
import matplotlib.pyplot as plt 
import random

mean, stddev, size = 50, 4, 100000
data = [random.gauss(mean, stddev) for c in range(size)]

mn = sum(data) / size
sd = (sum(x*x for x in data) / size 
      - (sum(data) / size) ** 2) ** 0.5

print("Sample mean = %g; Stddev = %g; max = %g; min = %g for %i values" 
      % (mn, sd, max(data), min(data), size))

plt.hist(data,bins=50)
Task: Statistics_Normal distribution
C: 
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <time.h>


#define NMAX 10000000


double mean(double* values, int n)
{
    int i;
    double s = 0;

    for ( i = 0; i < n; i++ )
        s += values[i];
    return s / n;
}


double stddev(double* values, int n)
{
    int i;
    double average = mean(values,n);
    double s = 0;

    for ( i = 0; i < n; i++ )
        s += (values[i] - average) * (values[i] - average);
    return sqrt(s / (n - 1));
}


double* generate(int n)
{
    int i;
    int m = n + n % 2;
    double* values = (double*)calloc(m,sizeof(double));
    double average, deviation;

    if ( values )
    {
        for ( i = 0; i < m; i += 2 )
        {
            double x,y,rsq,f;
            do {
                x = 2.0 * rand() / (double)RAND_MAX - 1.0;
                y = 2.0 * rand() / (double)RAND_MAX - 1.0;
                rsq = x * x + y * y;
            }while( rsq >= 1. || rsq == 0. );
            f = sqrt( -2.0 * log(rsq) / rsq );
            values[i]   = x * f;
            values[i+1] = y * f;
        }
    }
    return values;
}


void printHistogram(double* values, int n)
{
    const int width = 50;    
    int max = 0;

    const double low   = -3.05;
    const double high  =  3.05;
    const double delta =  0.1;

    int i,j,k;
    int nbins = (int)((high - low) / delta);
    int* bins = (int*)calloc(nbins,sizeof(int));
    if ( bins != NULL )
    {
        for ( i = 0; i < n; i++ )
        {
            int j = (int)( (values[i] - low) / delta );
            if ( 0 <= j  &&  j < nbins )
                bins[j]++;
        }

        for ( j = 0; j < nbins; j++ )
            if ( max < bins[j] )
                max = bins[j];

        for ( j = 0; j < nbins; j++ )
        {
            printf("(%5.2f, %5.2f) |", low + j * delta, low + (j + 1) * delta );
            k = (int)( (double)width * (double)bins[j] / (double)max );
            while(k-- > 0) putchar('*');
            printf("  %-.1f%%", bins[j] * 100.0 / (double)n);
            putchar('\n');
        }

        free(bins);
    }
}


int main(void)
{
    double* seq;

    srand((unsigned int)time(NULL));

    if ( (seq = generate(NMAX)) != NULL )
    {
        printf("mean = %g, stddev = %g\n\n", mean(seq,NMAX), stddev(seq,NMAX));
        printHistogram(seq,NMAX);
        free(seq);

        printf("\n%s\n", "press enter");
        getchar();
        return EXIT_SUCCESS;
    }
    return EXIT_FAILURE;
}

VB: Public Sub standard_normal()
    Dim s() As Variant, bins(71) As Single
    ReDim s(20000)
    For i = 1 To 20000
        s(i) = WorksheetFunction.Norm_S_Inv(Rnd())
    Next i
    For i = -35 To 35
        bins(i + 36) = i / 10
    Next i
    Debug.Print "sample size"; UBound(s), "mean"; mean(s), "standard deviation"; standard_deviation(s)
            t = WorksheetFunction.Frequency(s, bins)
    For i = -35 To 35
        Debug.Print Format((i - 1) / 10, "0.00");
        Debug.Print "-"; Format(i / 10, "0.00"),
        Debug.Print String$(t(i + 36, 1) / 10, "X");
        Debug.Print
    Next i
End Sub
Task: Statistics_Normal distribution
C#: using System;
using MathNet.Numerics.Distributions;
using MathNet.Numerics.Statistics;

class Program
{
    static void RunNormal(int sampleSize)
    {
        double[] X = new double[sampleSize];
        var norm = new Normal(new Random());
        norm.Samples(X);

        const int numBuckets = 10;
        var histogram = new Histogram(X, numBuckets);
        Console.WriteLine("Sample size: {0:N0}", sampleSize);
        for (int i = 0; i < numBuckets; i++)
        {
            string bar = new String('#', (int)(histogram[i].Count * 360 / sampleSize));
            Console.WriteLine(" {0:0.00} : {1}", histogram[i].LowerBound, bar);
        }
        var statistics = new DescriptiveStatistics(X);
        Console.WriteLine("  Mean: " + statistics.Mean);
        Console.WriteLine("StdDev: " + statistics.StandardDeviation);
        Console.WriteLine();
    }
    static void Main(string[] args)
    {
        RunNormal(100);
        RunNormal(1000);
        RunNormal(10000);
    }
}

C++: #include <random>
#include <map>
#include <string>
#include <iostream>
#include <cmath>
#include <iomanip>

int main( ) {
   std::random_device myseed ;
   std::mt19937 engine ( myseed( ) ) ;
   std::normal_distribution<> normDistri ( 2 , 3 ) ;
   std::map<int , int> normalFreq ;
   int sum = 0 ; 
   double mean = 0.0 ;
   double stddev = 0.0 ;
   for ( int i = 1 ; i < 10001 ; i++ ) 
      ++normalFreq[ normDistri ( engine ) ] ;
   for ( auto MapIt : normalFreq ) {
      sum += MapIt.first * MapIt.second ;
   }
   mean = sum / 10000 ;
   stddev = sqrt( sum / 10000 ) ;
   std::cout << "The mean of the distribution is " << mean << " , the " ;
   std::cout << "standard deviation " << stddev << " !\n" ;
   std::cout << "And now the histogram:\n" ;
   for ( auto MapIt : normalFreq ) {
      std::cout << std::left << std::setw( 4 ) << MapIt.first << 
	 std::string( MapIt.second / 100 , '*' ) << std::endl ;
   }
   return 0 ;
}
Task: Statistics_Normal distribution
C++: #include <random>
#include <map>
#include <string>
#include <iostream>
#include <cmath>
#include <iomanip>

int main( ) {
   std::random_device myseed ;
   std::mt19937 engine ( myseed( ) ) ;
   std::normal_distribution<> normDistri ( 2 , 3 ) ;
   std::map<int , int> normalFreq ;
   int sum = 0 ; 
   double mean = 0.0 ;
   double stddev = 0.0 ;
   for ( int i = 1 ; i < 10001 ; i++ ) 
      ++normalFreq[ normDistri ( engine ) ] ;
   for ( auto MapIt : normalFreq ) {
      sum += MapIt.first * MapIt.second ;
   }
   mean = sum / 10000 ;
   stddev = sqrt( sum / 10000 ) ;
   std::cout << "The mean of the distribution is " << mean << " , the " ;
   std::cout << "standard deviation " << stddev << " !\n" ;
   std::cout << "And now the histogram:\n" ;
   for ( auto MapIt : normalFreq ) {
      std::cout << std::left << std::setw( 4 ) << MapIt.first << 
	 std::string( MapIt.second / 100 , '*' ) << std::endl ;
   }
   return 0 ;
}

Go: package main

import (
    "fmt"
    "math"
    "math/rand"
    "strings"
)


func norm2() (s, c float64) {
    r := math.Sqrt(-2 * math.Log(rand.Float64()))
    s, c = math.Sincos(2 * math.Pi * rand.Float64())
    return s * r, c * r
}

func main() {
    const (
        n     = 10000
        bins  = 12
        sig   = 3
        scale = 100
    )
    var sum, sumSq float64
    h := make([]int, bins)
    for i, accum := 0, func(v float64) {
        sum += v
        sumSq += v * v
        b := int((v + sig) * bins / sig / 2)
        if b >= 0 && b < bins {
            h[b]++
        }
    }; i < n/2; i++ {
        v1, v2 := norm2()
        accum(v1)
        accum(v2)
    }
    m := sum / n
    fmt.Println("mean:", m)
    fmt.Println("stddev:", math.Sqrt(sumSq/float64(n)-m*m))
    for _, p := range h {
        fmt.Println(strings.Repeat("*", p/scale))
    }
}
Task: Statistics_Normal distribution
C++: #include <random>
#include <map>
#include <string>
#include <iostream>
#include <cmath>
#include <iomanip>

int main( ) {
   std::random_device myseed ;
   std::mt19937 engine ( myseed( ) ) ;
   std::normal_distribution<> normDistri ( 2 , 3 ) ;
   std::map<int , int> normalFreq ;
   int sum = 0 ; 
   double mean = 0.0 ;
   double stddev = 0.0 ;
   for ( int i = 1 ; i < 10001 ; i++ ) 
      ++normalFreq[ normDistri ( engine ) ] ;
   for ( auto MapIt : normalFreq ) {
      sum += MapIt.first * MapIt.second ;
   }
   mean = sum / 10000 ;
   stddev = sqrt( sum / 10000 ) ;
   std::cout << "The mean of the distribution is " << mean << " , the " ;
   std::cout << "standard deviation " << stddev << " !\n" ;
   std::cout << "And now the histogram:\n" ;
   for ( auto MapIt : normalFreq ) {
      std::cout << std::left << std::setw( 4 ) << MapIt.first << 
	 std::string( MapIt.second / 100 , '*' ) << std::endl ;
   }
   return 0 ;
}

Python: from __future__ import division
import matplotlib.pyplot as plt 
import random

mean, stddev, size = 50, 4, 100000
data = [random.gauss(mean, stddev) for c in range(size)]

mn = sum(data) / size
sd = (sum(x*x for x in data) / size 
      - (sum(data) / size) ** 2) ** 0.5

print("Sample mean = %g; Stddev = %g; max = %g; min = %g for %i values" 
      % (mn, sd, max(data), min(data), size))

plt.hist(data,bins=50)