def mean(*value)
sum = 0
count = 0.0
for i in value
sum = sum + i
count = count + 1
end
if count==0
return "no argument"
end
return sum/count
end
mean(1,2,3,4,5)
======================================================
SEE OUTPUT
(a) Write a Ruby function mean that computes the mean value of an arbitrary number of arguments. Function calls mean (1,2,3,4,5) mean 3 ,1 ,and "No arguments". (1) and mean should respect...
(b) Write a Ruby function sigma that uses your function mean and computes the standard deviation of an arbitrary number of arguments. Function calls sigma (1,2,1,2) , sigma (1) and sigma should respectively return 1 ,0,and "No arguments". (Hint: the standard deviation is the square root o variance, and variance is the mean value of squares minus the square of the mean value) (c) Write a Ruby function stat that computes and returns the mean value, standard deviation, and the...
Ruby Programming Language question, sorry its a little cut off: 1. Write a Ruby function mean that computes the mean value of an arbitrary number of arguments. The program mean (1,2,3,4,5)mean (1) mean should generate the following results: Mean [l, 2, 3, 4, 51 3 Mean [1] 1 No arguments 2. Show all numeric data types available in Ruby. Then show how to define integer constants in vari number systems. def mean (a) cin t 1. Write a Ruby function...
1. Write a statement that calls a function named showSquare, passing the value 10 as an argument. 2. Write the function prototype for a function called showSquare. The function should have a single parameter variable of the int data type and areturn type of void. 3. Write the function prototype for a function called showScoreswith a parameter list containing four integer variables and a return type of void. 4. Look at the following function definition: double getGrossPay(int hoursWorked, double payRate)...
Python Problem: Variance Explanation: Problem 1: Computing variance For this problem, you will write a function variance that takes a list whose elements are numbers (floats or ints), and returns their variance, a single number. (If you don't remember how to compute variance, check the lecture notebook; it's one of the intermediate steps in computing standard deviation.) You should not use NumPy or any other Python libraries for this problem. For now, worry only about correctness, not efficiency. Passing an...
The following are short Python calculations. Give the answer and the Python code for each. 1. What is the sum of the numbers from 22:100 incrementing by 2? Do this in two ways: Use a while statement and a for loop to do the calculation. (Hint: make sure the numbers include 100) 2. What is the mean, standard deviation of the square root of the numbers from 3 to 5 incrementing by 0.1? Use the linspace function from the numpy...
I really need help with this python programming assignment Program Requirements For part 2, i need the following functions • get floats(): It take a single integer argument and returns a list of floats. where it was something like this def get_floats(n): lst = [] for i in range(1,n+1): val = float(input('Enter float '+str(i)+': ')) lst.append(val) return lst • summer(): This non-void function takes a single list argument, and returns the sum of the list. However, it does not use...
*Write a parallel program pie.c in C or C++ (pie.cc) for Linux that computes an approximation of the number π using a series with N+1 terms.* --The series sum is partitioned in T non-overlapping partial sums, each computed by T separate child processes created with the fork() library function.* --This program demonstrates data parallelism and interprocess communication using pipes. Each child process could perform a (potentially) long computation on a separate CPU (or core). Depending on the computer architecture, the...
1. Table of descriptive statistical measures (arithmetic mean, standard deviation, smallest value and largest value) for the variables in the model with a detailed discussion of the table2. The equation is in the community form of the model you reached, then display the results of the estimated equation from the Gretl program with errors. Standard normal as well again with proper standard errors.3. Discuss and explain the results of the estimated model and then the number of reasons why the...
python 2..fundamentals of python 1.Package Newton’s method for approximating square roots (Case Study 3.6) in a function named newton. This function expects the input number as an argument and returns the estimate of its square root. The script should also include a main function that allows the user to compute square roots of inputs until she presses the enter/return key. 2.Convert Newton’s method for approximating square roots in Project 1 to a recursive function named newton. (Hint: The estimate of...
Needs to be done in visual studio. I keep having problems with making my own function to call for the statistics and the random number generator. they are both supposed to be separate functions from the main. Can anyone help? Language is C Overview: This third programming assignment will be the first to require the use of arrays. Like the second program, this program will be modular and make use of functions (including, this time, functions which process arrays). Brief...