xxxxxxxxxx
1
1
using Plots
xxxxxxxxxx
1
1
plotly()
xxxxxxxxxx
1
1
using Random, StatsBase
0x0001e240
-1659974861
1073470649
358281436
1073351076
-836744907
1073086183
1497051007
1072821109
960204239
1073516083
-342501482
1073266846
-1718403935
1073376000
-1321583464
1073263548
1129201718
1073404550
-1413096746
1073044152
-761652241
1073037584
-1988158346
1073300352
-1977759271
1347447899
1840933752
-1237490475
382
0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0x00000000000000000000000000000000
0x00000000000000000000000000000000
0x00000000000000000000000000000000
0x00000000000000000000000000000000
0x00000000000000000000000000000000
0x00000000000000000000000000000000
0x00000000000000000000000000000000
0x00000000000000000000000000000000
0x00000000000000000000000000000000
0x00000000000000000000000000000000
0x00000000000000000000000000000000
0x00000000000000000000000000000000
0x00000000000000000000000000000000
0x00000000000000000000000000000000
0x00000000000000000000000000000000
0x00000000000000000000000000000000
0x00000000000000000000000000000000
0x00000000000000000000000000000000
0x00000000000000000000000000000000
0x00000000000000000000000000000000
0x00000000000000000000000000000000
0x00000000000000000000000000000000
0x00000000000000000000000000000000
0x00000000000000000000000000000000
0x00000000000000000000000000000000
0x00000000000000000000000000000000
0x00000000000000000000000000000000
0x00000000000000000000000000000000
0x00000000000000000000000000000000
0x00000000000000000000000000000000
1002
0
xxxxxxxxxx
1
1
Random.seed!(123456)
20
xxxxxxxxxx
7
1
begin
2
PRODUCTOS_POR_LOTE = 120
3
MIN_DEFECTUOSOS_POR_LOTE = 3
4
MAX_DEFECTUOSOS_POR_LOTE = 8
5
N_ITERACIONES = 100
6
N_PRODUCTOS_EXTRAIDOS = 20
7
end
simulacion (generic function with 1 method)
xxxxxxxxxx
21
1
function simulacion(
2
N::Int;
3
prod_por_lote::Int = PRODUCTOS_POR_LOTE,
4
rango_defectuosos::UnitRange = MIN_DEFECTUOSOS_POR_LOTE:MAX_DEFECTUOSOS_POR_LOTE,
5
n_prod_extraidos::Int = N_PRODUCTOS_EXTRAIDOS
6
)::Float64
7
saldo_inicial::Float64 = 0.0
8
lote::BitArray{1} = BitArray(undef, prod_por_lote)
9
num_defectuosos::Int = 0
10
for i in 1:N
11
num_defectuosos = rand(rango_defectuosos)
12
fill!(lote, false)
13
lote[sample(1:prod_por_lote, num_defectuosos, replace = false)] .= true
14
if (sum(sample(lote, n_prod_extraidos, replace = false)) ≥ 2)
15
saldo_inicial -= 25.0
16
else
17
saldo_inicial += 100.0
18
end
19
end
20
saldo_inicial / N
21
end
f (generic function with 1 method)
xxxxxxxxxx
6
1
function f(x::Int,y::Int)
2
if y < x
3
return NaN
4
end
5
simulacion(10000; rango_defectuosos=x:y)
6
end
xxxxxxxxxx
1
1
plot(0:10, 0:10, f, st=:scatter, xlabel="Minimo de defectos", ylabel="Máximo de defectos")
x
1
surface(0:10, 0:10, f, xlabel="Minimo de defectos", ylabel="Máximo de defectos", camera=(-20,160))