Skip to content
Programming101
Programming101

Learn everything about programming

  • Home
  • CS Subjects
    • IoT – Internet of Things
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programming101
Programming101

Learn everything about programming

HackerRank Day 6: The Central Limit Theorem III | 10 Days of Statistics solution

YASH PAL, 31 July 2024

In this Hackerrank Day 6: The Central Limit Theorem III 10 Days of Statistics problem You have a sample of 100 values from a population with a mean of 500 and with a standard deviation of 80. Compute the interval that covers the middle 95% of the distribution of the sample mean; in other words, compute A and B such that P(A<x<B)=0.95. Use the value of z=1.96.

HackerRank Day 6: The Central Limit Theorem III | 10 Days of Statistics solution

Problem solution in Python programming.

# Enter your code here. Read input from STDIN. Print output to STDOUT
# true population distribution
mu, sigma = 500, 80

# sample mean distribution
muS, sigmaS = mu, sigma/(100**0.5)

# confidence intervals of sample mean dist
A = mu - (1.96*sigmaS)
B = mu + (1.96*sigmaS)

print(round(A,2))
print(round(B,2))

Problem solution in Java Programming.

import java.io.*;
import java.util.*;

public class Solution {

    public static void main(String[] args) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        float mean = scan.nextFloat();
        float sigma = scan.nextFloat();
        float goal = scan.nextFloat();
        float z = scan.nextFloat();
        
        float sampleSigma = sigma/(float)Math.sqrt(n);
        
        float A = mean - z*sampleSigma;
        float B = mean + z*sampleSigma;
        System.out.printf("%.2fn",A);
        System.out.printf("%.2fn",B);
    }  
    
}

Problem solution in C++ programming.

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;


int main() {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */   
    double x1,x2;
    x1=-8*1.96+500;
    x2=8*1.96+500;
    printf("%.2fn%.2f",x1,x2);
    return 0;
}

Problem solution in C programming.

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main() {

        double mean   = 500;
        double std    = 80;
        int    n      = 100;
        double zScore = 1.96; 
        
        double marginOfError =(double) (zScore * std) / (sqrt(n));

        /* Print output */
        printf("%.2fn", mean - marginOfError);
        printf("%.2fn", mean + marginOfError);
    return 0;
}

Problem solution in JavaScript programming.

function processData(input) {
    //Enter your code here
    input = input.split('n')

    let mx = parseFloat(input[0]),
        m = parseFloat(input[1]),
        sd = parseFloat(input[2]),
        i = parseFloat(input[3]),
        z = parseFloat(input[4])

    function confidenceInterval(z, sd, mx) {
        return z * (sd / Math.sqrt(mx))
    }

    console.log((m - confidenceInterval(z, sd, mx)).toFixed(2))
    console.log((m + confidenceInterval(z, sd, mx)).toFixed(2))
} 

process.stdin.resume();
process.stdin.setEncoding("ascii");
_input = "";
process.stdin.on("data", function (input) {
    _input += input;
});

process.stdin.on("end", function () {
   processData(_input);
});

10 days of statistics coding problems solutions

Post navigation

Previous post
Next post
  • Automating Image Format Conversion with Python: A Complete Guide
  • HackerRank Separate the Numbers solution
  • How AI Is Revolutionizing Personalized Learning in Schools
  • GTA 5 is the Game of the Year for 2024 and 2025
  • Hackerrank Day 5 loops 30 days of code solution
How to download udemy paid courses for free

Pages

  • About US
  • Contact US
  • Privacy Policy

Programing Practice

  • C Programs
  • java Programs

HackerRank Solutions

  • C
  • C++
  • Java
  • Python
  • Algorithm

Other

  • Leetcode Solutions
  • Interview Preparation

Programming Tutorials

  • DSA
  • C

CS Subjects

  • Digital Communication
  • Human Values
  • Internet Of Things
©2025 Programming101 | WordPress Theme by SuperbThemes