Borrar filtros
Borrar filtros

Consider a loop of string with unit length. Take n cuts independently and randomly along the string, what is the expected length of the smallest and the largest piece?

1 visualización (últimos 30 días)
This is what I did.
The probability is (1+(1-n)x)^n
So, expected value of x is it integral for x varies from 0 to 1/n which evaluates to 1/n^2
If this is right how should I write the code?
  7 comentarios
Guillaume
Guillaume el 9 de Feb. de 2016
Editada: Guillaume el 9 de Feb. de 2016
I think Jan's point was that a loop, having no start and end point, can't really have a length. Perimeter might be a more appropriate term.
Vin Sen  Lee
Vin Sen Lee el 10 de Feb. de 2016
So, i just got clarification on this problem. My task is to write a function whose input is a number of cuts and output is the 1x2 array of the form [xmin xmax] where xmin is your experimental expected value of the smallest cut and xmax is your experimental expected value of the largest cut.

Iniciar sesión para comentar.

Respuestas (1)

Are Mjaavatten
Are Mjaavatten el 8 de Feb. de 2016
Your question is not very clear. The code below is an answer to: How can I code a test of this result?
N=100000; % Number of samples
n=8; % Number of cuts
d = zeros(N,n); % Allocate space for results
for i = 1:N
a = sort(rand(1,n)); % Draw random cut poins and distribute them along the string
b = [a(end)-1,a]; % Join ends
d(i,:) = sort(diff(b)); % Sort the pieces by length
end
mean_lengths = mean(d); % mean_lengths(i) is the mean length of the i'th shortest piece
disp(mean_lengths);
  2 comentarios
Walter Roberson
Walter Roberson el 9 de Feb. de 2016
Editada: Walter Roberson el 9 de Feb. de 2016
mean_lengths(end) is the mean of the longest.
The shortest out of all of the runs is min(d(:)) and the longest out of all of the runs is max(d(:)) (those might occur on different runs.)

Iniciar sesión para comentar.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by