Question

2. Suppose the probability density function for American male height is roughly (in inches x) h(x)e-a-69)2/5.6 2.8V2 a) Write

0 0
Add a comment Improve this question Transcribed image text
Answer #1


Matlab code for finding integration using different method clear all close all %Probability distribution function h-e (x) (1.%integration using Simpson 1/3 and Simpson 3/8 method val simp 13-Simp13_int(h, a,b,n); val-simp 38-sinp38-int (h , a,b, n) ;end %%Matlab function forsimpson 3/8 Method function val-Simp38_int(f,a,b,n) f is the function for integration % a is the low

%Matlab code for finding integration using different method
clear all
close all
%Probability distribution function
h=@(x) (1./(2.8.*sqrt(2*pi)))*exp((-(x-69).^2)/5.6);
%height between 65 to 70
a=65; b=70; n=2;
%Function for which integration have to do
fprintf('\nProbability distribution function h(x)=\n')
disp(h)
fprintf('Height between [%2.2f to %2.2f] is \n',a,b)

%Integration using Simpson 1/3 and Simpson 3/8 method
    val_simp13=Simp13_int(h,a,b,n);
    val_simp38=Simp38_int(h,a,b,n);
    val_trap =trap_int(h,a,b,n);
fprintf('\tIntegration using Simpson 1/3 for 2 interval is %f.\n',val_simp13)

fprintf('\tIntegration using Simpson 3/8 for 2 interval is %f.\n',val_simp38)

fprintf('\tIntegration using Trapizoidal method for 2 interval is %f.\n',val_trap)

%height between 65 to 70
a=65; b=70; n=4;
%Function for which integration have to do
fprintf('\nProbability distribution function h(x)=\n')
disp(h)
fprintf('Height between [%2.2f to %2.2f] is \n',a,b)

%Integration using Simpson 1/3 and Simpson 3/8 method
    val_simp13=Simp13_int(h,a,b,n);
    val_simp38=Simp38_int(h,a,b,n);
    val_trap =trap_int(h,a,b,n);
fprintf('\tIntegration using Simpson 1/3 for 4 interval is %f.\n',val_simp13)

fprintf('\tIntegration using Simpson 3/8 for 4 interval is %f.\n',val_simp38)

fprintf('\tIntegration using Trapizoidal method for 4 interval is %f.\n',val_trap)

%height between 65 to 70
a=65; b=1000; n=4000;
%Function for which integration have to do
fprintf('\nProbability distribution function h(x)=\n')
disp(h)
fprintf('Height greater than %d is \n',a)

%Integration using Simpson 1/3 and Simpson 3/8 method
    val_simp13=Simp13_int(h,a,b,n);
    val_simp38=Simp38_int(h,a,b,n);
    val_trap =trap_int(h,a,b,n);
fprintf('\tIntegration using Simpson 1/3 for 4 interval is %f.\n',val_simp13)

fprintf('\tIntegration using Simpson 3/8 for 4 interval is %f.\n',val_simp38)

fprintf('\tIntegration using Trapizoidal method for 4 interval is %f.\n',val_trap)

     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%Matlab function for mid point integration
function val=trap_int(f,a,b,N)
    % func is the function for integration
    % a is the lower limit of integration
    % b is the upper limit of integration
    % N number of rectangles to be used
    val=0;
    %splits interval a to b into N+1 subintervals
    xx=linspace(a,b,N+1);
    dx=xx(2)-xx(1); %x interval
    %loop for Riemann integration
        for i=2:length(xx)-1
            xx1=xx(i);
            val=val+dx*double(f(xx1));
        end
       val=val+dx*(0.5*double(f(xx(1)))+0.5*double(f(xx(end))));
end

%%Matlab function for Simpson 1/3 Method
function val=Simp13_int(f,a,b,n)
%f=function for which integration have to do
%a=upper limit of integration
%b=lower limit of integration
%n=number of subintervals

    zs=f(a)+f(b);   %simpson integration
    %all x values for given subinterval
    xx=linspace(a,b,n+1);
    dx=(xx(2)-xx(1)); %x interval
    %Simpson Algorithm for n equally spaced interval
    for i=2:n
        if mod(i,2)==0
            zs=zs+4*f(xx(i));
        else
            zs=zs+2*f(xx(i));
        end
    end
    %result using Simpson rule
    val=double((dx/3)*zs);
end

%%Matlab function forSimpson 3/8 Method
function val=Simp38_int(f,a,b,n)
    % f is the function for integration
    % a is the lower limit of integration
    % b is the upper limit of integration
    % n is the number of trapizoidal interval in [a,b]
  
    %splits interval a to b into n+1 subintervals
    xx=linspace(a,b,n+1);
    dx=(xx(2)-xx(1)); %x interval
    val=f(a)+f(b);
    %loop for trapizoidal integration
        for i=2:n
            if mod(i-1,3)==0
                val=val+2*double(f(xx(i)));
            else
                val=val+3*double(f(xx(i)));
            end
        end
    %result using midpoint integration method
    val=(3/8)*dx*val;
end
  
%%%%%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%%%%%

Add a comment
Know the answer?
Add Answer to:
2. Suppose the probability density function for American male height is roughly (in inches x) h(x)e-a-69)2/5.6 2.8V2 a) Write a code to estimate the probability that an American male is between 65 an...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • (1 point) Suppose that f(x) is the (continuous) probability density function for heights of American men, in inches...

    (1 point) Suppose that f(x) is the (continuous) probability density function for heights of American men, in inches, and suppose that f(69) Think carefully about what the meaning of this mathematical statement is 0.21. (a) Approximately what percent of American men are between 68.5 and 69.5 inches tall? Approximately 21 percent. (b) Suppose F(h) is the cumulative distribution function off.if F(69) = 0.5, estimate each of F(68.5) F(68)

  • Use Matlab code Consider the following function sin(x) Using the following parameters in your functions: -func:...

    Use Matlab code Consider the following function sin(x) Using the following parameters in your functions: -func: the function/equation that you are required to integrate -a, b: the integration limits n: the number of points to be used for the integration I:Integral estimate a) Write a function capable of performing numerical integration of h(x) using the composite trapezoidal rule. Use your function to integration the equation with 9 points. Write a function capable of performing numerical integration of h(x) using the...

  • Show work by hand and also using MATLAB code. Model 1 Given a polynomial f(x) Write a first-order approximation of f(x), given the value of f(x) at two points Plot the polynomial and the first-or...

    Show work by hand and also using MATLAB code. Model 1 Given a polynomial f(x) Write a first-order approximation of f(x), given the value of f(x) at two points Plot the polynomial and the first-order approximation on a graph Write a second-order approximation of f(x), given the value at three points. Plot the polynomial, the first-order and second-order approximations on a graph Find the integral Exactly Using trapezoidal rule Using composite trapezoidal rule Using Simpson's 1/3 rule . Calculate the...

  • Write MATLAB code g(x)=x+a*f(x) f(x)=(e^x)+(x^2)-x-4 function f(x) is stored in fogp1.m (c) (1) Create a file...

    Write MATLAB code g(x)=x+a*f(x) f(x)=(e^x)+(x^2)-x-4 function f(x) is stored in fogp1.m (c) (1) Create a file gopgi.m to calculate the function glir, a) (see Preparation, ex. 7c) function [y] =gopg1(x,a) % input: x, a % output: y y= .....; (2) Create a file sucsub1.m and write a program that calculates the solution using the method of successive substitution. Calculate the values of g(x, a) by making multiple calls to the function gopg1(x, a). Take xo = 1.3 as starting value...

  • 10. Write a one-page summary of the attached paper? INTRODUCTION Many problems can develop in activated...

    10. Write a one-page summary of the attached paper? INTRODUCTION Many problems can develop in activated sludge operation that adversely affect effluent quality with origins in the engineering, hydraulic and microbiological components of the process. The real "heart" of the activated sludge system is the development and maintenance of a mixed microbial culture (activated sludge) that treats wastewater and which can be managed. One definition of a wastewater treatment plant operator is a "bug farmer", one who controls the aeration...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT