13 views

Uploaded by uc

save

- Pra 00883
- How_to_make_a_decision_The_Analytic_Hier.pdf
- 2013.01.09-ECE595E-L02
- Linear
- 1-s2.0-S0893965904815179-main.pdf
- Examples Sheik
- 08 Matrices and Determinants 19
- (Thefreestudy.com) GATE Quick Refresher Guide by the GATE Academy
- New EM Quiz13
- Class 12 Chapter 3. Matrices
- ch03partSolution
- If Em
- Euclidean Distance of Images
- Eigen Mode
- About Matrix
- 9
- Formulation and Comparison of Two Recursive Matrix Algorithms for Modeling Layered Diffraction Gratings
- Review of Linear Algebra (1)
- Elemental matrices for Finite element electromagnetics
- 13b FP3 June 2013
- Example 2 Lecture 39
- Diff Eq's Odd Answers
- Defense Tech (1)
- Assignment 2
- Reduction of a Symmetric Matrix to Tridiagonal Form - Givens and Householder Reductions
- Introduction to Matlab
- Mathcad (Tutorial)
- EC 400 Quizzes for Class 2
- 07814377
- syb
- gms
- intro_fluxtransform_supplement
- 103102019
- onthemaxwellstefanapproachtomulti.pdf
- Multicomponent Mass Transfer:Fluxes & velocities
- PDE Farsi
- AmuzeshMatlab(Matlab Guide)
- Matlab Farsi

You are on page 1of 2

Machine Learning

**Institute of Computational Science Dept. of Computer Science, ETH Z¨rich u
**

Peter Orbanz E-Mail porbanz@inf.ethz.ch Web http://www.inf.ethz.ch/∼porbanz/ml

**Series (Introducing Matlab)
**

Problem 1 (First steps): Please skip this if you are already familiar with matlab.

1. Have a look at the matlab functions rand, randn, eig, load, save. Use matlab’s online help (type help rand etc). 2. Write a function to compute the expression y (x) = sin (x) + cos (3x). The function should be implemented as a matlab m-ﬁle, say ﬁrst.m. 3. What is the eﬀect of the command x=linspace(0,3.5,50)? 4. Generate a matrix containing the values of x, y as its ﬁrst and second column. 5. Take a look at matlab’s plot function. Use it to produce a plot of the function y (deﬁned in 2) for x ∈ [0, 5]. You do not need to submit anything for this problem. Problem 2 (Sampling a d-dimensional Gaussian distribution): We consider the problem of sampling a multivariate normal (Gaussian) distribution. Matlab provides a function called randn, which produces pseudo-random samples for a normal distribution with parameters µ = (0, . . . , 0) and Σ = 1, where 1 is the d-dim. identity matrix. We wish to produce samples from a Gaussian N (µ, Σ) with arbitrary parameters µ and Σ, so we have to transform the sample in a suitable manner. Our approach is based on the eigenvalue structure of symmetric matrices: The eigenvectors of a full-rank symmetric matrix form an orthogonal basis of the underlying vector space. With respect to this basis, the matrix is diagonal, with the eigenvalues as diagonal entries. Denote this diagonal matrix of eigenvalues D and the matrix describing the change of basis V . Then Σ = V DV −1 . V is orthogonal (since it describes a change of basis between two orthonormal bases), so V −1 = V t and Σ = V DV t . This representation of Σ is called the Schur decomposition. We can produce a sample from a normal distribution with parameters µ, Σ by drawing a sample vector g from N (0, 1) using randn, changing basis, and adding the expectation vector: √ g = V Dg + µ . ˜ √ √ As you will recall from linear algebra, D = diag Dii . 1. Implement a function x = GSAMPLE(mu, Sigma, n) to produce n draws from a d-dimensional Gaussian. (The dimension d is implicitly speciﬁed by mu and Sigma.) 2. Test your implementation: Apply the matlab functions mean and cov to a suﬃciently large sample generated by your program. They should approximately reproduce your input parameters. 3. Produce 100 samples each in two three dimensions, using the parameter values µ = (1, 1) , Σ = and 5 2 0 2 1 t and µ = (1, 1, 1) , Σ = 2 3 1 , respectively. Plot your results using the functions plot 1 2 0 1 1 and plot3. When using the plot function, always supply ’x’ as ﬁnal argument, i.e. use a function call of the form plot(A,B,’x’). This tells matlab to display each point as an x-mark. (If your plot looks somewhat like a random walk, you got it wrong.) Please turn in:

t

1000}. Plot the histograms using the plot function. and see how stable the result is with respect to diﬀerent samples. For n = 100000. We will draw a number n of sample points from a one-dimensional Gaussian. this is about sample size and reliability of estimates. Produce four histograms with n = 100 and Nbins = 10. plot one histogram each for Nbins ∈ {10. using a Gaussian distribution as an example data source. Give a brief discussion of the results. Please turn in your plots and discussion. 5. 100.) 4. Remember. Finally. 2 .• A listing of your numerical test results in (2). Problem 3 (Sample Size): A recurrent theme in statistical data analysis is that large numbers of observations are required in order to obtain reliable estimates. The present problem aims at illustrating this phenomenon. Make sure that plots are suﬃciently labeled. • The plots produced in (3). (Matlab lets you to display multiple plots within a single ﬁgure with the subplot function. Repeat the procedure with n = 100000. Please complete the following steps: 1. • Use the matlab function randn to draw n samples from a one-dimensional Gaussian distribution (µ = 0. The basic procedure is the following: • Choose a number n of sample points and a number Nbins of histogram bins. 3. sort them into a histogram. 2. σ = 1). • Turn the complete data sample into a histogram using the function hist. choose n = 100 and Nbins = 1000.

- Pra 00883Uploaded byMassimiliano Sacchi
- How_to_make_a_decision_The_Analytic_Hier.pdfUploaded byRogelio Lazo Arjona
- 2013.01.09-ECE595E-L02Uploaded byUltrazord
- LinearUploaded bySheikh Riasat
- 1-s2.0-S0893965904815179-main.pdfUploaded byValentino Lunardi
- Examples SheikUploaded bySheik Mohammed
- 08 Matrices and Determinants 19Uploaded byVaibhav Tripathi
- (Thefreestudy.com) GATE Quick Refresher Guide by the GATE AcademyUploaded byRashmi Sahoo
- New EM Quiz13Uploaded bySingh Karan
- Class 12 Chapter 3. MatricesUploaded byShreya Singh
- ch03partSolutionUploaded byAhmed Nabil
- If EmUploaded byapi-3700440
- Euclidean Distance of ImagesUploaded byrezacz
- Eigen ModeUploaded bySanthos Kumar
- About MatrixUploaded byJulian Gutierrez
- 9Uploaded bysatishaparna
- Formulation and Comparison of Two Recursive Matrix Algorithms for Modeling Layered Diffraction GratingsUploaded byFrancisco Javier Pérez
- Review of Linear Algebra (1)Uploaded byDeni Chan
- Elemental matrices for Finite element electromagneticsUploaded byftdlaks
- 13b FP3 June 2013Uploaded byPat
- Example 2 Lecture 39Uploaded bySyed Ali Haider
- Diff Eq's Odd AnswersUploaded byBrad Stalder
- Defense Tech (1)Uploaded bySharyn Villarez
- Assignment 2Uploaded byPheonix Desire
- Reduction of a Symmetric Matrix to Tridiagonal Form - Givens and Householder ReductionsUploaded byAntonio Peixoto
- Introduction to MatlabUploaded byKashan Khan
- Mathcad (Tutorial)Uploaded byGiannis Papanikolopoulos
- EC 400 Quizzes for Class 2Uploaded byAvijit Puri
- 07814377Uploaded bypedro
- sybUploaded bySugunakar Amirishetty