Write MATLAB code that uses Monte Carlo integration for
estimating
where a = -2 and b = 2
Matlab code :
func = @(x) sin(.*x).^2 ; % Given function
a = -2
b = 2
integral (func, a, b)
NoOfSample = 10000 ;
r = (b-a).*rand(1000,1) + a; % Generate random number of array size 10000 in range -2 to 2
rf = 4.0 * func (r); % normalized function
mean = mean (rf) ; % calculating mean of function
error = std (rf) / sqrt (Nsample) ; % computing error
fprintf ( 'Monte Carlo estimate (Nsample=%d) %f +/- %f \n' , NoOfSample, mean, error);
Write MATLAB code that uses Monte Carlo integration for estimating where a = -2 and b...
Write MATLAB code that uses Monte Carlo integration for estimating where a = -2 and b = 2 cb sin(da cb sin(da
Volume of a cap (formula given) using Monte Carlo integration (MATLAB). The volume of a cap in terms of the sphere's radius, r, and depth, d, is given by Vcap = (3r – d) Suppose we did not know this expression or maybe we just want to check this expression. Assume r = 2 m and d = 1.5 m. Use Monte- Carlo integration to find the volume of such a cap. To start the prob- lem take 1,000 random...
Find the mean and variance using Monte Carlo integration, where x > 0.
MONTE CARLO SIMULATION: So I am trying to figure out a MATLAB code to generate a Monte Carlo simulation for my mean and standard deviation values. I have a material (fat) with mean and standard deviation values as well as mean and standard deviation values for its thickness. I need to figure out a code that will plot and generate a monte carlo simulation. Any help would be greatly appreciated. Thanks
Write a MATLAB script using a Monte Carlo method to estimate the volume of a 3-dimensional ball of radius R=0.5.
I want Matlab code related to 14.35. 14.35 A Monte Carlo analysis can be used for optimization. For example, the trajectory of a ball can be computed with 2 |(P14.35) x+yo 2 cos20o y=(tan0o)x where y the height (m), Go = the initial angle (radians), the initial velocity (m/s), g 9.81 m/s, and yo vo = 25 m/s, and Oo = 50", determine the maximum height and the corresponding x distance (a) analytically with calcu- lus and (b) numerically with...
in Matlab, Use the Monte Carlo analysis to compute the area of a circle with radius 1. print out your code, at least one figure on which the circle and ‘dart hits’ are shown, and numerical results for N=10, 100,1000. For each N, repeat the calculation at least 5times.
Q. 2 a) Using only Unif 0,1) random variates, use a Monte Carlo algorithm to approximate the value of the Gamma function 0 by considering the function as an expectation of a function of a random variable. b) Show that if a Monte Carlo simulation of size N is used then the variance of the Monte Carlo estimator is Var (「(a))- 2a-1)-[「(a)]2] provided that α > 0.5. c) Write an R function to implement the method returning the estimated value...
Write a Java program that uses the Monte Carlo method to estimate the value of PI. This method uses the unit circle inscribed in a square with sides of length 2 and random numbers to perform the estimation. The estimation works as follows: • Two random numbers are generated during each iteration of a loop. • The random numbers are each in the range of -1 to 1. One random number is the x-coordinate and the other is the y-coordinate....
Exercise 2 (Monte Carlo integration). Let (Xk)kzl be i.i.d. Uniform([0, 1]) RVs and let f: [0,1] -- R be a continuous function. For each n2 1, let (f(X)f(X2).+f(Xn)) (3) In = -- .. + Sof(x) dx in probability. (i) Suppose o f (x)| dx (ii) Further assume that f lf(x)2 dx <o0. Use Chebyshef's inequality to show that :< oo. Show that In P (IIn-I2 alVnVar(f(X1)) a2 f(x)2 dx (4)