Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #49282 > unrolled thread
| Started by | "WJ" <w_a_x_man@yahoo.com> |
|---|---|
| First post | 2016-07-21 16:46 +0000 |
| Last post | 2016-07-21 16:46 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.forth
Weighted choices "WJ" <w_a_x_man@yahoo.com> - 2016-07-21 16:46 +0000
| From | "WJ" <w_a_x_man@yahoo.com> |
|---|---|
| Date | 2016-07-21 16:46 +0000 |
| Subject | Weighted choices |
| Message-ID | <nmqu9v$km6$1@dont-email.me> |
R:
weighted.random.choices = function(choices, n)
{ matrix(choices, 2) -> m
sample( m[1,], n, prob=m[2,], rep=TRUE)
}
summary(factor(unlist(
weighted.random.choices(list("quarter1",0.1, "quarter2",0.1, "half",0.2),
100000))))
half quarter1 quarter2
50045 24736 25219
In ANS Forth?
--
The report card by the American Society of Civil Engineers showed the national
infrastructure a single grade above failure, a step from declining to the point
where everyday things simply stop working the way people expect them to. ---
washingtonpost.com/local/trafficandcommuting/us-infrastructure-gets-d-in-annual-report/2013/03/19/c48cb010-900b-11e2-9cfd-36d6c9b5d7ad_story.html
Back to top | Article view | comp.lang.forth
csiph-web