close all; clc; N = 1000000; % Number of samples NB =

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
[MATLAB] I would like to repeat the matlab code below as an exponential distribution. How should I do? plz answer ------------------------------- clear all; close all; clc; N = 1000000; % Number of samples NB = 50; % Number blocks S = 49; % Number of the sets %% PDF P = zeros(NB,1); % Initialization of the blocks for PDF x = rand(N,S); % Generate S sets of uniformly distributed samples in [0,1] x = sum(x,2); x_mean = mean(x); x_var = var(x); x_std = sqrt(x_var); x_min = floor(x_mean - 3 * x_std); % Set the minimum x_max = ceil(x_mean + 3 * x_std); % Set the maximum scaler = NB/6; % Heuristics for n=1:N ind = ceil(NB*x(n)/S); P(ind) = P(ind) + 1; end pdf_sampled = (NB/N)/S * P; x_axis = [1/(2*NB):S/NB:S*(1-1/(2*NB))]; figure(1) subplot(2,1,1); bar(x_axis, pdf_sampled, 'BarWidth', 1); axis_range = [x_min x_max 0.0 2.0]; axis(axis_range); hold on; grid on; title(sprintf('PDF from the sampled data with %d samples.', N)); %% CDF C = zeros(NB,1); % Initialization of the blocks for CDF for n=1:NB %ind = ceil(NB*x(n)/S); C(n) = sum(P(1:n,1)/NB); end cdf_sampled = (NB/N) * C; x_axis = [1/(2*NB):S/NB:S*(1-1/(2*NB))]; x_range = [x_min-2*x_std x_max+2*x_std]; axis_range = [x_range 0.0 1.5]; figure(1) subplot(2,1,2); bar(x_axis, cdf_sampled, 'BarWidth', 1); axis(axis_range); hold on; grid on; title(sprintf('CDF from the sampled data with %d samples.', N)); %% Built-in Function x = linspace(x_min, x_max, N); pdf_builtin = normpdf(x, x_mean, x_std); % Gaussian density pdf figure(1) subplot(2,1,1) plot(x, pdf_builtin,'LineWidth',2) cdf_builtin = normcdf(x, x_mean, x_std); % Gaussian density cdf figure(1) subplot(2,1,2) plot(x, cdf_builtin,'LineWidth',2)
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Knowledge Booster
Multiple table
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education