Construct a three-column array where column 1 is rnorm(100,2,2), column 2 is rnorm(100, 4, 4) and column 3 is rnorm(100, 0, 1). Then write the r code to change this array into an array where each column has exactly mean 0 and exactly variance 1.
#********************R code**********************
column1 = rnorm(100,2,2)
column2 = rnorm(100, 4, 4)
column3 = rnorm(100, 0, 1)
--
array = cbind(column1, column2, column3)
data_frame = as.data.frame(array)
#this function will standardize the data (mean zero, unit
variance).
scaled_data <- scale(data_frame)
print('final array having each 0 mean and 1 variance')
print(as.matrix(scaled_data))
# check that we get mean of 0 and sd of 1
print(colMeans(scaled_data)) # faster version of apply(scaled.dat,
2, mean)
#apply(scaled.dat, 2, sd)
cat('\n\nsummary containig mean of each column is\n')
#-----You can see Mean in the summary as 0 for each colum
print(summary(scaled_data))
#apply wiil find apply fun operation which is finding standard
deviation sd(third argument)
#here 2 means it will find standard deviation for each column(1
means it will find sd for ech row)
cat('\n\nVairance of each column is: \n')
print(apply(scaled_data, 2, sd))
#***************Output Screenshot***************
$************Code screenshot****************
#****Please do let me know if you have any doubts or want me to modify the code *************
Construct a three-column array where column 1 is rnorm(100,2,2), column 2 is rnorm(100, 4, 4) and...
Write the vb.Net code that displays a 2-column table in a textbox, displaying (1,2,3, ...., 100) in array, while also showing the i'th value for each value in the array
I have x=[1 ; 2 ; 4 ; 5 ; 7 ; 9 ; 3] can you write matlab code of column array that calculate midpoint between every two points. eg [(1+2)/2; (2+4)/2;(4+5)/2;(5+7)/2...] answer should give x_midpoint=[1.5 ; 3 ; 4.5 ; .....]
9. Lo Shu Magic Square The Lo Shu Magic Square is a grid with three rows and three columns that has the following properties: The grid contains the numbers 1 through 9 exactly. The sum of each row, each column, and each diagonal all add up to the same number. This is shown in the following figure · 15 4 9 2-15 3 5 7-15 81 615 15 15 15 15 Write a program that simulates a magic square using...
Refer to the following array definition for questions 1 & 2 int numberArray[9)[11] 1. Write a statement that assigns 145 to the first column of the first row of this array. 2. Write a statement that assigns 18 to the last column of the last row of this array. values is a two-dimensional array of floats, with 10 rows and 20 columns. Write code that sums all of the elements in the array and stores the sum in the variable...
Write a C++ program that will create an array with a given number of elements. Use size = 10 for demonstration purposes, but write the program where the size of the array can be changed by changing the value of one constant. Fill the array with random numbers between 0 and 100. Write the program to perform the following operations: 1. Find and display the largest value in the array. 2. Find and display the smallest value in the array....
Matlab!
Use Matlab to calculate array X and array Y. The first column is
time (1, 2, 3 ...), and the second column is value (0 and 1).
When the value of array X is 0, the value of array Y is itself at
the same time.
When the value of array X is 1, the value of array Y will become
the value of the previous Y(i-1)
The data of the array is given, just how to change the...
1.The code box below includes a live 2 dimensional array variable called gridNums. This array holds integers. You cannot see its declaration or initialization. What value is in the zeroth (initial) position of the second row? Print this array entry to the console. (Note: remember that the second row is actually row 1). Enter your code in the box below. 2.The code box below includes a live 3x3 2-dimensional array variable called fredsNums. This array holds integers. You cannot see...
f a as a sequence of adjacent array elements such that each value in the run array was of size 10 9. We define a "run" of elements o (except for the first) is one greater than the previous and looked like: value. For example, say the 3 2 16 9 7 8 9 2 a: position 0 3 We have three runs in this array: (1) between 9,10,1, 12) and, (3) between positions 7 and 8, (15, 16) positions...
The last element in each array in a 2D array is incorrect. It’s your job to fix each array so that the value 0 is changed to include the correct value. In the first array, the final value should be the length of the first array. In the second array, the final value should be the sum of the first value, and the second to last value in the array. In the third array, the final value should be the...
Row Column Generated Data New Aeay Random Number (0-1) Multiply 100 Subset Rows Sub-Amey Add Insert Into Aray Subset Column Sub-Amay Add aj Figure 3.4 Block Diagram of Task 3 REVIEW QUESTIONS 1. Explain the working of the code (block diagram) of task 3. 2, Suppose we want to extract first six rows from "New Array" to form a new row sub- array. Suggest your changes in the code of task 3. 3. What changes should be done to insert...