Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

Question 4,5 , using R

### 1.2 Matrix

1. **Create a vector with 100 random numbers.**

2. **Transfer the above vector into a 10 by 10 matrix \( M \).**

3. **Find the transposed matrix \( M^T \).** 
   - Print the value of the element that is in the second row and the first column of \( M^T \).

4. **Write a nested loop to calculate the inner product between \( M^T \) and \( M \).**
   - The result is also a matrix \( N = \langle M^T, M \rangle \).

5. **Calculate the same inner product using operator \(\%\ast\%\).** 
   - And compare the two results.
expand button
Transcribed Image Text:### 1.2 Matrix 1. **Create a vector with 100 random numbers.** 2. **Transfer the above vector into a 10 by 10 matrix \( M \).** 3. **Find the transposed matrix \( M^T \).** - Print the value of the element that is in the second row and the first column of \( M^T \). 4. **Write a nested loop to calculate the inner product between \( M^T \) and \( M \).** - The result is also a matrix \( N = \langle M^T, M \rangle \). 5. **Calculate the same inner product using operator \(\%\ast\%\).** - And compare the two results.
Expert Solution
Check Mark
Step 1

Solution -

A) A=rand(200,1) % 200 random numbers use rand or randn
b=randi(200,100,1) % randomly choose 100
 
A(b)=NaN % replace those 100 chosen above with NaN's
 
We may use the sample function to generate a random vector for a set of values. The sample function just requires that we pass the range and sample size. For instance, the command sample(1:100,20) can be used to generate a random sample of size 20 for a range of values between 1 and 100. If the sample size is greater than 100, replace=TRUE can be used as seen in the example below.
 
Example1 - 
 x1<-sample(1:100,20)
 x1
 
Output-
[1] 39 64 73 80 78 38 57 16  5 40  3 45 96 20 51 13 42 35 63 25
 Example2
x2<-sample(1:100,200,replace=TRUE)
x2

Output-

[1]   5  95  65  82  73  73  33  81  93   7  96  18  80  38  90  82  99  65
 [19]  26  75  58  73  88  14  36  13  45  37  86  46  95  77  91  40  99  64
 [37]  22  79  33  53  10  25  77  83   1  39  71  19  88  50  64  44  52  25
 [55]  92   6  41  10  32  96  82  62  18  82  28  46  57  93  14  53   5  94
 [73]  84  89  28  42  40  21  70  63   7  83  43  41  41  31  65   5  22  62
 [91]  24  25  58   3  28  37  71   2  48  40  31  67  87  99  38  91  14  78
[109]  65  18  89  29  66  94   4  75  53  98  59  57  66  94  85  29  22  98
[127]  43  60  67  91  27 100  57  75 100  10  98  95  63  29   3  83   6  70
[145]  69  59  72  89  92  33  59  67  91  36   4  33  70  80  75  80  52  14
[163]  31  55  39  63  83  20  38  83  65  94  18  36  94  82  87  74  57  32
[181]  89  69  72  13  72  95  66  38  36  80  99  27  48  12  30 100  86  92
[199]  12  44

 

Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education