Question

In: Statistics and Probability

1. Write a code that constructs a matrix with 5 rows that contain the number 1...

1. Write a code that constructs a matrix with 5 rows that contain the number 1 up to 30. Your output matrix must be filled by the columns.

2. Create the vector_a containing five numeric values 5,7,8,9,10 and vector_b containing five numeric values 2,4,7,9,19. Write the output of the sum of vector_a and vector_b.

3. Create the vector_a containing five numeric values 5,7,8,9,10 and vector_b containing five numeric values 2,4,7,9,19. Write a code that combines vector_a and vector_b.

Solutions

Expert Solution

Ans 1)

Here we have to write a code that constructs a matrix with 5 rows that contain the number 1 up to 30 and output matrix must be filled by the columns.

 > m=matrix(1:30,byrow = FALSE,nrow=5) #it gives require matrix > m  [,1] [,2] [,3] [,4] [,5] [,6] [1,] 1 6 11 16 21 26 [2,] 2 7 12 17 22 27 [3,] 3 8 13 18 23 28 [4,] 4 9 14 19 24 29 [5,] 5 10 15 20 25 30

Ans 2)

 > a=c(5,7,8,9,10) > b=c(2,4,7,9,19) > output1=a+b #gives sum of two vector > output1 [1] 7 11 15 18 29

Ans3)

 > a=c(5,7,8,9,10) > b=c(2,4,7,9,19) > output2=c(a,b) #it combines the two vector > output2  [1] 5 7 8 9 10 2 4 7 9 19

I have also attached the R code of this question.

m=matrix(1:30,byrow = FALSE,nrow=5) #it gived the matrix of 1:30 fillesd by column
m

a=c(5,7,8,9,10)
b=c(2,4,7,9,19)
output1=a+b    #gives sum of two vector
output1

a=c(5,7,8,9,10)
b=c(2,4,7,9,19)
output2=c(a,b) #it combines the two vector
output2


Related Solutions

[PLEASE USE C++] Write a function to read values of a number of rows, number of...
[PLEASE USE C++] Write a function to read values of a number of rows, number of columns, 2 dimensional (2D) array elements and display the 2D array in a matrix form. Input 2 3 1 4 5 2 3 0 Where, First line of represents the number of rows. Second line of input represents the number of columns. Third line contains array elements of the 1st row and so on. Output 1 4 5 2 3 0 where There must...
Write a script to display the following patterns on the screen. Number of rows and columns...
Write a script to display the following patterns on the screen. Number of rows and columns are taken from the command arguments; if they are missing, set default to 3 (rows) and 4 (columns). Hint: you will use a nested loop. **** **** **** a) Display the source code in an editor (#4-11) b) Execute your script in the terminal, and display the command and the result (#4-12)
Find the rook polynomial and an expression for the number of matchings of 5 men (rows)...
Find the rook polynomial and an expression for the number of matchings of 5 men (rows) with 5 women (columns) given the following forbidden pairings: (M1,W4), (M2,W2), (M3,W3), (M4,W2), (M4,W4), (M5,W1), (M5,W3), (M5,W45). Answer is 5! - 8x4! + 21x3! - 20x2!+ 6x1!, please explain how to get it, thanks.
2. Write a c++ program that takes from the user the ​number of courses​ and constructs...
2. Write a c++ program that takes from the user the ​number of courses​ and constructs 3 ​dynamic 1D arrays​ with size courses+1. Each array represents a student. Each cell in the array represents a student’s mark in a course. In the last cell of each 1D array you should calculate the average mark of that student. Then output the average mark of all students in each course. Delete any allocated memory. Example Number of courses : 4 50 60...
Consider the matrix P = I - X(XTX)-1X T . If matrix X has 4 rows...
Consider the matrix P = I - X(XTX)-1X T . If matrix X has 4 rows and 6 columns, what are the dimensions of matrix I? Prove that P is idempotent.
Write a MIPS assembly language to transpose a square integer matrix in code
Write a MIPS assembly language to transpose a square integer matrix in code
Need to write a code using c# Strassen’s Algorithm for matrix multiplication.
Need to write a code using c# Strassen’s Algorithm for matrix multiplication.
CODE IN PYTHON 1. Write a program that asks the user for the number of slices...
CODE IN PYTHON 1. Write a program that asks the user for the number of slices of pizza they want to order and displays the total number of dollar bills they owe given pizza costs 3 dollars a slice.  Note: You may print the value an integer value. 2. Assume that y, a and b have already been defined, display the value of x: x =   ya+b    3. The variable start_tees refers to the number of UD T-shirts at the start...
write a program in java that contain a class for botique . data member include code...
write a program in java that contain a class for botique . data member include code , color , size , quantity . your class should contains all accessor and mutator methods , non paraqmetric constructor , parametric constructor , input andvidsplay method
Write a function such that given a number N, display the N*N multiplication matrix from 1...
Write a function such that given a number N, display the N*N multiplication matrix from 1 to N. Then, write a C++ program such that, it prints the multiplication matrices of numbers 1,4,7, and 10 using a loop concept. Check the sample output below, to see how the program should work. Make sure to have your output exactly the same as the below output.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT