Question

Write a python code that calculates the mean and median of a sample of 100 uniform...

Write a python code that calculates the mean and median of a sample of 100 uniform random numbers between 0 and 2 and the percentage of points in the sample that are greater than 1.

Homework Answers

Answer #1

Required Python Code:

import random 
import numpy
def Rand(start, end, num): 
    res = [] 
    for j in range(num): 
        res.append(random.uniform(start, end)) 
    return res 
res = Rand(0, 2, 100)
print("Mean of 100 random uniform numbers between 0 and 2 is ", numpy.mean(res))
print("Median of 100 random uniform numbers between 0 and 2 numbers is ", numpy.median(res))
percentage = 0
for i in res : 
    if i > 1 : 
        percentage = percentage + 1
print("Percentage of numbers greater than 1 is ", percentage, "%")

SAMPLE OUTPUT:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Python code Write a complete program with for loop which calculates the sum of the numbers...
Python code Write a complete program with for loop which calculates the sum of the numbers from 1 to 100
Write a python code that will ask the user to enter an integer number n. Construct...
Write a python code that will ask the user to enter an integer number n. Construct a recursive function that prints numbers 1 to n in the form “11223344..nn”.
Write a Python program which calculates the average of the numbers entered by the user through...
Write a Python program which calculates the average of the numbers entered by the user through the keyboard. Use an interactive loop and ask the user at each iteration if he/she wants to enter more numbers. At the end dispay the average on the screen. Using built-in library functions for finding average is not allowed. Sample output of the program: Enter a number > 23 More numbers (yes or no)? y Enter a number > 4 Do you have more...
[10 marks] (SumDigits.java) Write code that asks the user to enter an integer between 100 and...
[10 marks] (SumDigits.java) Write code that asks the user to enter an integer between 100 and 999. The program finds and displays the three digits in the number. The program also calculates and displays the sum of the three digits. A sample run is shown below: Enter a number between 100 and 999: 528 The three digits in the number are: 5 2 8 The sum of the three digits is: 15
(SumDigits.java) Write code that asks the user to enter an integer between 100 and 999. The...
(SumDigits.java) Write code that asks the user to enter an integer between 100 and 999. The program finds and displays the three digits in the number. The program also calculates and displays the sum of the three digits. A sample run is shown below: Enter a number between 100 and 999: 528 The three digits in the number are: 5 2 8 The sum of the three digits is: 15 Note: You must use integer division and modulo division to...
Write a code in R markdown Given sample data 1,2,3,2,2,2,6,0,2,3 (1) Estimate the percent bias of...
Write a code in R markdown Given sample data 1,2,3,2,2,2,6,0,2,3 (1) Estimate the percent bias of the sample median as a fraction of the standard error. (2) Find an appropriate 90% confidence interval for the true median and interpret. (3) Estimate the probability that the sample median exceeds two, i.e., P(sample median > 2) (4) Does the data provide sufficient/significant evidence that the mean exceeds 2?
How to code this in python Write a program that computes and prints the first 1000...
How to code this in python Write a program that computes and prints the first 1000 prime numbers - simply write out each prime number on a new line. In implementing this solution I want you to define 2 functions: is_prime which can be used to test whether a number is a prime (e.g. is_prime(17) returns True but is_prime(9) returns False) and compute_primes which will return an array (or Python list) of the first n primes where n is passed...
In a positively skewed distribution: a. the median is less than the mean. b. the median...
In a positively skewed distribution: a. the median is less than the mean. b. the median equals the mean. c. the median is larger than the mean. d. the mean can be larger or smaller than the median. What is the mean of x, given the function below? f(x) =(1/10) e-x/10     x 0 a. 100 b. 1,000 c. 10 d. 0.10 The starting salaries of individuals with an MBA degree are normally distributed with a mean of $40,000 and a...
8) Write Python code for a function called occurances that takes two arguments str1 and str2,...
8) Write Python code for a function called occurances that takes two arguments str1 and str2, assumed to be strings, and returns a dictionary where the keys are the characters in str2. For each character key, the value associated with that key must be either the string ‘‘none’’, ‘‘once’’, or ‘‘more than once’’, depending on how many times that character occurs in str1. In other words, the function roughly keeps track of how many times each character in str1 occurs...
""" ''' Write a python code to push all zeors to the end of an array...
""" ''' Write a python code to push all zeors to the end of an array ''' import numpy as np def Move_a(i):    num = len(a)    for k in range (i, num-1): a[k] = a[k+1] a[num-1] = 0    return a a = np.array([0,1,4,7,0,9,12,0,0,15,0,21]) #length of array (len) num = len(a) print (num) for i in range(0,num): if (a[i] == 0): #Functioon call to Move_a() a = Move_a(i)       print ("the array looks like") print (a) My...