# STA5107_FRADE_HW7 - STA5107 Dr Srivastava Homework 7 Jaime...

This preview shows pages 1–6. Sign up to view the full content.

STA5107: Dr. Srivastava Homework 7 Jaime Frade 1. OUTPUT a) Plot f(x) over the interval [-4,10] b) f(x) = exp(-1/2*a^2)+2*exp(-1/2*(a-3)^2)+exp(-1/2*(a-6)^2) f’(x) = -a*exp(-1/2*a^2)+2*(-a+3)*exp(-1/2*(a-3)^2)+(-a+6)*exp(-1/2*(a-6)^2) c) See code

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

View Full Document
STA5107: Dr. Srivastava Homework 7 Jaime Frade d)
STA5107: Dr. Srivastava Homework 7 Jaime Frade

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

View Full Document
STA5107: Dr. Srivastava Homework 7 Jaime Frade
STA5107: Dr. Srivastava Homework 7 Jaime Frade CODE %part a and part b clear all ; clc; close all % Part (a) x=[-4:0.1:10]; for i=1:length(x) Fx(i)=exp(-x(i).^2/2)+2*exp(-(x(i)-3).^2/2)+exp(-(x(i)-6).^2/2); end plot(x,Fx) % Part (b) syms a Fa=exp(-a.^2/2)+2*exp(-(a-3).^2/2)+exp(-(a-6).^2/2) diff(Fa,a) % Part c and d % % Homework 8.1 % Part c and d sigma=0.1; T = 1; N = 1000; run_times = 50; alpha = 0.995; t_small = zeros(1, run_times); for index = 1:run_times x = zeros(1, N + 1); x(1) = 10*randn; for t = 1:N y_t = x(t) + sigma*f_prime_func(x(t)) + sqrt(T*sigma)*randn; rho = min(exp((f_func(y_t) - f_func(x(t)))/T), 1); z = rand; if z < rho x(t+1) = y_t; else x(t+1) = x(t); end T = alpha * T; end t_small(index) = x(t+1); end figure(1) plot(t_small); title([ 'Evolution of the process of f(x) with run time = ' int2str(run_times)]);

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern