-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Un pequeño experimento con la ruleta rusa
- Loading branch information
Guillem Borrell
committed
Apr 22, 2011
1 parent
2301f94
commit 9927557
Showing
3 changed files
with
2,433 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
function [ avret,stdret ] = ruleta (d,j,N,c) | ||
|
||
%% Tengo una ruleta imperfecta de 61 casillas (0+36) de la que sé que | ||
%% el rojo (con el negro funcionaría exactamente de la misma manera) | ||
%% tiene más probabilidades de aparecer que el negro. Si su | ||
%% probabilidad debería ser 18/37, en realidad es 18/37*(1+d), donde d | ||
%% es un número pequeño. Mi objetivo es saber, mediante una simulacion | ||
%% Montecarlo, el ritmo al que me enriquezco o me empobrezco. | ||
|
||
%% El experimento deberá repetirse muchas veces puesto que el valor | ||
%% que me interesa es el valor asintótico después de infinitos juegos | ||
|
||
%% d es la desviación de la ruleta | ||
%% j es el número de apuestas | ||
%% N es el número de juegos | ||
%% c es la cantidad que apuesto en cada tirada | ||
|
||
avret = 0; | ||
stdret = 0; | ||
|
||
for i=1:N | ||
bet = rand(j,1); | ||
ret = cumsum((bet<(18/37*(1+d)))-(bet>(18/37*(1+d)))); | ||
avret += ret; | ||
stdret += ret.^2; | ||
end | ||
|
||
avret = avret/N; | ||
stdret = sqrt(stdret/N-avret.^2); | ||
|
||
endfunction |
Oops, something went wrong.