Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The question asks for R function which gets vector as input and its output would be multiple and addition of that vector Submission returns matrices

The question asks for R function which gets vector as input and its output would be multiple and addition of that vector

image text in transcribed
Submission returns matrices of the exact dimension specified. . Data: All questions will use the following datastructures: rTrain ( Inx/ is a matrix of training data, where each row is a training point, and each column is a feature. - rest E Rmix) is a matrix of test data, where each row is a test point, and each column is a feature. y Train ( {1, ...,c}"x] is a vector of training labels - yTest E (1, ..., c)mxl is a (hidden) vector of test labels. 1 Logspace Arithmetic [10 pts] When working with very small and very large numbers (such as probabilities), it is useful to work in logspace to avoid numerical precision issues. In logspace, we keep track of the logs of numbers, instead of the numbers themselves. (We generally use natural logs for this). For example, if p(x) and p(y) are proba- bility values, instead of storing p(x) and p(y) and computing p(x) *p(y), we work in log space by storing log p(z), log p(y), loglp(r) * p(y)], where log[p(r) * p(y)] is computed as log p(r) + logp(y). The challenge is to add and multiply these numbers while remaining in logspace, without exponentialing. Note that if we exponentiale our numbers at any point in the calculation it completely defeats the purpose of working in log space. 1. Logspace Multiplication [5 pts] Complete logProd=function(x) which takes as input a vector of numbers in logspace (i.e., I; = logpi), and returns the product of these numbers in logspace - i.e., logProd(x) = log II, pi- 2. Logspace Addition [5 pts] Complete logSum=function(x) which takes as input a vector of numbers in logspace (i.e., I; = log pi), and returns the sum of these numbers in logspace - i.e., logSum(x) = log ); pi

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The How And Why Of One Variable Calculus

Authors: Amol Sasane

1st Edition

1119043417, 9781119043416

More Books

Students also viewed these Mathematics questions