By using Matlab: Longley data set. The Longley data set of labor statistics was
ID: 3604514 • Letter: B
Question
By using Matlab: Longley data set. The Longley data set of labor statistics was one of the first used to test the accuracy of least squares computations. You don't need to go to the NIST Web site to do this problem, but if you are interested in the background, you should see the Longley page at . The data set is available in NCM in the file longley.dat. You can bring the data into MATLAB with load longley.dat y longley(:,1) There are 16 observations of 7 variables, gathered over the years 1947 to 1962. The variable y and the 6 variables making up the columns of the data matrix are y = Total Derived Employ!nent. = GNP Implicit Price Deflater x2 Gross National Product, r3Unemployment, T4 = Size of Armed Forces, rs Noninstitutional Population Age 14 and Over, Zg=Year The objective is to predict y by a linear combination of a constant and the six r's: (a) Use the MATLAB backslash operator to compute A-a, ,As. This involves augmenting X with a column of all 1's, corresponding to the constant term. (b) Compare your 's with the certified values [3] (c) Use errorbar to plot y with error bars whose magnitude is the difference between y and the least squares fit. (d) Use corrcoef to compute the correlation coefficients for X without the column of 1's. Which variables are highly correlated? (e) Normalize the vector y so that its mean is zero and its standard deviation is one. You can do this with -mean(y); y/std(y) y = y y Do the same thing to the columns of X. Now plot all seven normalized vari- ables on the same axis. Include a legendExplanation / Answer
SOLUTION IN MATLAB:
You are almost there with your logic. But to seperate the numbers with comma, you need to use join() function, In that case for loop is not necessary to iterate over the array. Please find below the corrected code:
import random
def main():
#Create a list
numbers = [0] * 7
# Populate the list with random numbers.
for index in range(7):
numbers[index] = random.randint (0, 9)
# Display the random numbers.
print ('Here are your Lottery numbers:')
print(','.join(map(str,numbers))) #Separate current number from next number with commas.
# Call the main function.
main()
Output:
Here are your Lottery numbers:
9,0,8,8,7,0,9
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.