Skip to content

Instantly share code, notes, and snippets.

View jdwyah's full-sized avatar

Jeff Dwyer jdwyah

View GitHub Profile
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
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)
@jdwyah
jdwyah / 4 moves
Created June 28, 2013 23:55
Landing square distribution when going to Jail after 3 doubles or Goto Jail.
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
@jdwyah
jdwyah / 4 moves
Created June 28, 2013 22:21
Relative likelihood of landing on a square in first 6 monopoly moves.
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
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}
),
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}
),
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
select id, sum from similarities
order by 2,1
limit 10
Caused by: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException ("Unrecognized field "hubspotUserId" (class com.hubspot.socialmonitoring.StreamItemAction), not marked as ignorable (8 known properties: , "streamItemActionsGuid", "userId", "type", "createdAt", "text", "streamItemId", "updatedAt", "url"]) at [Source: org.eclipse.jetty.server.HttpInput@60356eb0; line: 1, column: 92] (through reference chain: com.hubspot.socialmonitoring.StreamItemAction["hubspotUserId"])") ? at line -1
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException ? in from at line 79
com.fasterxml.jackson.databind.DeserializationContext ? in reportUnknownProperty at line 579
com.fasterxml.jackson.databind.deser.std.StdDeserializer ? in handleUnknownProperty at line 672
com.fasterxml.jackson.databind.deser.BeanDeserializerBase ? in handleUnknownProperty at line 906
com.fasterxml.jackson.databind.deser.BeanDeserializer ? in deserializeFromObject at line 328
com.fasterxml.jackson.databind.deser.BeanDeserializer ? in d
Caused by: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException ("Unrecognized field "hubspotUserId" (class com.hubspot.socialmonitoring.StreamItemAction), not marked as ignorable (8 known properties: , "streamItemActionsGuid", "userId", "type", "createdAt", "text", "streamItemId", "updatedAt", "url"]) at [Source: org.eclipse.jetty.server.HttpInput@541d511a; line: 1, column: 92] (through reference chain: com.hubspot.socialmonitoring.StreamItemAction["hubspotUserId"])") ? at line -1
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException ? in from at line 79
com.fasterxml.jackson.databind.DeserializationContext ? in reportUnknownProperty at line 579
com.fasterxml.jackson.databind.deser.std.StdDeserializer ? in handleUnknownProperty at line 672
com.fasterxml.jackson.databind.deser.BeanDeserializerBase ? in handleUnknownProperty at line 906
com.fasterxml.jackson.databind.deser.BeanDeserializer ? in deserializeFromObject at line 328
com.fasterxml.jackson.databind.deser.BeanDeserializer ? in d