Write a program to analyze scientific data. Input: The first line of the file co
ID: 3822146 • Letter: W
Question
Write a program to analyze scientific data. Input: The first line of the file contains the number of data readings. The following lines contain the data presented as floating-point numbers. Compute: The mean mean = bar x = x_1 + x_2 + .. x_n/n The Standard Deviation. S_N = squareroot 1/N sigma^N_i=1 (x_i - bar x)^2. Output: Output is to be to a file. Output the standard deviation first. Output the data in the original order 8 values per line in tabular format. Output to single column: the data from low to high, and the words "out of range" if the value mean + 1.5 S_N. Function to input number of data readings, allocate memory and input actual data. Function to allocated memory for an array of pointers to the actual data and set these pointers pointing to the actual data. Function to sort the data using the array of pointers to the data so that original data is not altered. Use the selection sort algorithm. Function to output.Explanation / Answer
solution--
As you have not mentioned any particular programming language, I am using python here, it is simple and dynamic.
save the file as meanstd.py and run using python meanstd.py
import numpy as np
def inp():
n=int(input())
arr=[0 for i in range(n)]
for i in range(n):
arr[i]=float(input())
return arr
def out(std,mean):
print('standard deviation is ',std)
print('mean is ',mean)
arr=inp()
arr.sort()
mean=np.mean(arr)
std=np.std(arr)
out(std,mean)
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.