This file contains hidden or 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
target as ( | |
select symptom_id, symptom_severity from latest_symptom_surveys lss | |
join symptom_reports sr on sr.symptom_survey_id = lss.id | |
where lss.user_id = #{self.id} | |
), |
This file contains hidden or 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
similarities as ( | |
select distinct | |
ss.user_id as id, | |
sum((sr.symptom_severity - coalesce(target.symptom_severity,0)) ^ 2) OVER (PARTITION BY ss.user_id), | |
count(sr.id) OVER (PARTITION BY ss.user_id) as count | |
from latest_symptom_surveys ss | |
join symptom_reports sr on sr.symptom_survey_id = ss.id | |
left join target on target.symptom_id = sr.symptom_id | |
join users u on u.id = ss.user_id |
This file contains hidden or 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
select id, sum from similarities | |
order by 2,1 | |
limit 10 |
This file contains hidden or 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
WITH | |
latest_symptom_surveys as ( | |
select * from (select *, rank() over (PARTITION BY user_id order by date desc, id desc) from symptom_surveys ss) ranked | |
where rank = 1 | |
), | |
target as ( | |
select symptom_id, symptom_severity from latest_symptom_surveys lss | |
join symptom_reports sr on sr.symptom_survey_id = lss.id | |
where lss.user_id = #{self.id} | |
), |
This file contains hidden or 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
100000 players making 4 moves will land: | |
Average 10000.0 | |
390 0.04x than avg Go | |
179 0.02x than avg Mediterranean Avenue (Purple) | |
2867 0.29x than avg Community Chest | |
5463 0.55x than avg Baltic Avenue (Purple) | |
8304 0.83x than avg Income Tax | |
11501 1.15x than avg Reading Railroad (Railroad) | |
14768 1.48x than avg Oriental Avenue (Light Blue) | |
18202 1.82x than avg Chance |
This file contains hidden or 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
100000 players making 4 moves will land: | |
Going to Jail after 3 doubles or Goto Jail. | |
Average 10000.0 | |
251 0.03x than avg Go 0 | |
126 0.01x than avg Mediterranean Avenue (Purple) 1 | |
2865 0.29x than avg Community Chest 2 | |
5722 0.57x than avg Baltic Avenue (Purple) 3 | |
8343 0.83x than avg Income Tax 4 | |
11488 1.15x than avg Reading Railroad (Railroad) 5 | |
14598 1.46x than avg Oriental Avenue (Light Blue) 6 |
This file contains hidden or 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
10000 simulations of 30 guests making 6 moves. | |
Avg servings 2.8508 95th pct 6 max 10 Go | |
Avg servings 2.706 95th pct 5 max 10 Mediterranean Avenue (Purple) | |
Avg servings 3.3667 95th pct 6 max 12 Community Chest | |
Avg servings 4.0179 95th pct 7 max 13 Baltic Avenue (Purple) | |
Avg servings 4.5918 95th pct 8 max 13 Income Tax | |
Avg servings 5.2334 95th pct 9 max 14 Reading Railroad (Railroad) | |
Avg servings 5.9482 95th pct 10 max 16 Oriental Avenue (Light Blue) | |
Avg servings 6.7892 95th pct 11 max 17 Chance | |
Avg servings 6.0857 95th pct 10 max 16 Vermont Avenue (Light Blue) |
This file contains hidden or 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
def move(curMonte, space, moves, doubles) | |
dieOne = rand(6) + 1 | |
dieTwo = rand(6) + 1 | |
doubles += 1 if dieOne == dieTwo | |
nextSpace = (space + dieOne + dieTwo) % NUM_SQUARES | |
SQUARES[curMonte][nextSpace] += 1 | |
if moves > 1 | |
move(curMonte, nextSpace, moves - 1, doubles) | |
end | |
end |
This file contains hidden or 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
MONTE.times do |m| | |
GUESTS.times do |i| | |
move(m, 0, TOTAL_MOVES, 0) | |
end | |
end |
This file contains hidden or 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
MONTE = 100000 | |
NUM_SQUARES = 40 | |
SQUARES = [] | |
MONTE.times do | |
SQUARES << [0] * NUM_SQUARES | |
end |