https://www.coursera.org/learn/machine-learning/exam/dbM1J/octave-matlab-tutorial

Octave Tutorial

5 试题

1.

Suppose I first execute the following Octave commands:

A = [1 2; 3 4; 5 6];

B = [1 2 3; 4 5 6];

Which of the following are then valid Octave commands? Check all that apply and assume all options are written in an Octave command. (Hint: A' denotes the transpose of A.)

C = A * B;

C = B' + A;

C = A' * B;

C = B + A;

答案: ab (C = A * B 和 C = B' + A;)

2.

Question text

Let A=⎡⎣⎢⎢16594211714310615138121⎤⎦⎥⎥.

Which of the following indexing expressions gives B=⎡⎣⎢⎢16594211714⎤⎦⎥⎥? Check all that apply.

B = A(:, 1:2);

B = A(1:4, 1:2);

B = A(0:2, 0:4)

B = A(1:2, 1:4);

答案 :ab (B = A(:, 1:2);和 B = A(1:4, 1:2);)

3.

Let A be a 10x10 matrix and x be a 10-element vector. Your friend wants to compute the product Ax and writes the following code:

v = zeros(10, 1);

for i = 1:10

for j = 1:10

v(i) = v(i) + A(i, j) * x(j);

end

end

How would you vectorize this code to run without any FOR loops? Check all that apply.

v = A * x;

v = Ax;

v =x'* A;

v = sum (A * x);

答案: a. v = A * x;

v = Ax :Undefined function or variable 'Ax'.

4.

Say you have two column vectors v and w, each with 7 elements (i.e., they have dimensions 7x1). Consider the following code:

z = 0;

for i = 1:7

z = z + v(i) * w(i)

end

Which of the following vectorizations correctly compute z? Check all that apply.

z = sum (v .* w);

z = w' * v;

z = v * w';

z = w * v';

答案: ab (z = sum (v .* w);和 z = w' * v; )

column vectors 列向量

5.

In Octave, many functions work on single numbers, vectors, and matrices. For example, the sin function when applied to a matrix will return a new matrix with the sin of each element. But you have to be careful, as certain functions have different behavior. Suppose you have an 7x7 matrix X. You want to compute the log of every element, the square of every element, add 1 to every element, and divide every element by 4. You will store the results in four matrices, A,B,C,D. One way to do so is the following code:

for i = 1:7

for j = 1:7

A(i, j) = log(X(i, j));

B(i, j) = X(i, j) ^ 2;

C(i, j) = X(i, j) + 1;

D(i, j) = X(i, j) / 4;

end

end

Which of the following correctly compute A,B,C, or D? Check all that apply.

C = X + 1;

D = X / 4;

B = X .^ 2;

B = X ^ 2;

答案: abc

B = X .^ 2 而不是 X ^ 2

Coursera machine learning 第二周 quiz 答案 Octave/Matlab Tutorial的更多相关文章

  1. Coursera machine learning 第二周 quiz 答案 Linear Regression with Multiple Variables

    https://www.coursera.org/learn/machine-learning/exam/7pytE/linear-regression-with-multiple-variables ...

  2. Coursera machine learning 第二周 编程作业 Linear Regression

    必做: [*] warmUpExercise.m - Simple example function in Octave/MATLAB[*] plotData.m - Function to disp ...

  3. Machine Learning – 第2周(Linear Regression with Multiple Variables、Octave/Matlab Tutorial)

    Machine Learning – Coursera Octave for Microsoft Windows GNU Octave官网 GNU Octave帮助文档 (有900页的pdf版本) O ...

  4. 吴恩达Machine Learning 第一周课堂笔记

    1.Introduction 1.1 Example        - Database mining        Large datasets from growth of automation/ ...

  5. 吴恩达《深度学习》-第一门课 (Neural Networks and Deep Learning)-第二周:(Basics of Neural Network programming)-课程笔记

    第二周:神经网络的编程基础 (Basics of Neural Network programming) 2.1.二分类(Binary Classification) 二分类问题的目标就是习得一个分类 ...

  6. Coursera Machine Learning 作业答案脚本 分享在github上

    Github地址:https://github.com/edward0130/Coursera-ML

  7. Coursera, Machine Learning, notes

      Basic theory (i) Supervised learning (parametric/non-parametric algorithms, support vector machine ...

  8. Coursera Machine Learning : Regression 评估性能

    评估性能 评估损失 1.Training Error 首先要通过数据来训练模型,选取数据中的一部分作为训练数据. 损失函数可以使用绝对值误差或者平方误差等方法来计算,这里使用平方误差的方法,即: (y ...

  9. Coursera Machine Learning : Regression 多元回归

    多元回归 回顾一下简单线性回归:一个特征,两个相关系数 实际的应用要比这种情况复杂的多,比如 1.房价和房屋面积并不只是简单的线性关系. 2.影响房价的因素有很多,不仅仅是房屋面积,还包括很多其他因素 ...

随机推荐

  1. Makefile之嵌套执行make

    1.在Makefile中 一般使用一个总控Makefile来指明文件的编译规则 如: subsystem: cd subdir && $(MAKE) 其等价于 subsystem: $ ...

  2. HTML5 Canvas 动态勾画等速螺线

    等速螺线亦称阿基米德螺线,得名于公元前三世纪希腊数学家阿基米德.阿基米德螺线是一个点匀速离开一个固定点的同时又以固定的角速度绕该固定点转动而产生的轨迹.在此向这位古代最伟大的数学家致敬.用Canvus ...

  3. Laravel之目录结构

    一.根目录 新安装的 Laravel 应用包含许多文件夹:• app 目录包含了应用的核心代码:• bootstrap 目录包含了少许文件用于框架的启动和自动载入配置,还有一个cache 文件夹用于包 ...

  4. C++ 模板详解(一)(转)

    C++模板 模板是C++支持参数化多态的工具,使用模板可以使用户为类或者函数声明一种一般模式,使得类中的某些数据成员或者成员函数的参数.返回值取得任意类型. 模板是一种对类型进行参数化的工具: 通常有 ...

  5. C语言中使用库函数解析命令行参数

    在编写需要命令行参数的C程序的时候,往往我们需要先解析命令行参数,然后根据这些参数来启动我们的程序. C的库函数中提供了两个函数可以用来帮助我们解析命令行参数:getopt.getopt_long. ...

  6. MySQL性能优化的最佳20+条经验(转)

    今天,数据库的操作越来越成为整个应用的性能瓶颈了,这点对于Web应用尤其明显.关于数据库的性能,这并不只是DBA才需要担心的事,而这更是我们程序 员需要去关注的事情.当我们去设计数据库表结构,对操作数 ...

  7. Android 函数回调

    1 http://blog.csdn.net/xyz_lmn/article/details/8631195 我感觉fragment和activity的通信形象的解释了函数的回调,看别人的博客越看越迷 ...

  8. IBM Rational Appscan使用之扫描结果分析

    转自:http://www.nxadmin.com/penetration/825.html 之前有IBM Rational Appscan使用详细说明的一篇文章,主要是针对扫描过程中配置设置等.本文 ...

  9. Hive优化策略

    hive优化目标 在有限的资源下,运行效率高. 常见问题 数据倾斜.Map数设置.Reduce数设置等 hive运行 查看运行计划 explain [extended] hql 例子 explain ...

  10. nginx限速

    nginx 要实现限速,完整的实现是要限制客户端请求频率,并发连接和传输速度 1.请求限制 Nginx 请求限制的功能来自于 ngx_http_limit_req_module 模块.使用它需要首先在 ...