STA5106_FRADE_HW2

STA5106_FRADE_HW2 - STA5106: Dr. Srivastava Homework 2...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
STA5106: Dr. Srivastava Homework 2 Jaime Frade 1. variance.m OUTPUT >> x=randn(1,100); >> variance3(x) variance3 = 0.9258 CODE function V=variance3(x) g=x(1); s1=0; s2=0; k=0; E=0.01; n=size(x,2); while (k<n) while k=k+1; s1= s1+(x(k)-g); s2=s2+(x(k)-g)*(x(k)-g); end if (k<n) gn=(s1/k)+g; s2 = s2 -k*(gn-g)+(gn-g)-2*(gn-g)*s1; s1=0; gn=0; end end m = s1/n+g; variance3 = s2/n - (s1/n)^2 end
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
STA5106: Dr. Srivastava Homework 2 Jaime Frade 2. backsub.m OUTPUT >> x = [12 10 13 10;0 7 1 4; 0 0 3 2; 0 0 0 4] x = 12 10 13 10 0 7 1 4 0 0 3 2 0 0 0 4 >> y = [1;1;1;1] y = 1 1 1 1 >> backsub(x,y) ans = -0.285714285714286 -0.023809523809524 0.166666666666667 0.250000000000000 >> b = x\y b = -0.285714285714286 -0.023809523809524 0.166666666666667 0.250000000000000 Comments: Test the function by using built-in matlab operator
Background image of page 2
STA5106: Dr. Srivastava Homework 2 Jaime Frade CODE %works same as built-in funtion operator, backslash\ %solves a system, Ax=b, where A is an upper %right triangluar matrix. %Not possible: solve an upper Triag matrix for nonsigular A
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/14/2011 for the course STAT 5106 taught by Professor Staff during the Fall '08 term at FSU.

Page1 / 6

STA5106_FRADE_HW2 - STA5106: Dr. Srivastava Homework 2...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online