Talk:Probabilistic choice

From Rosetta Code
Revision as of 17:25, 16 April 2011 by rosettacode>Balrog (random versus pseudorandom)

formatting trouble

I tried to add the SAS code, but it kept messing up the entry for tcl. Here is it is, if anyone who can format it is watching:

data test; do i = 1 to 1000000;

  x=rand("TABLE",(1/5),1/6,1/7,1/8,1/9,1/10,1/11);
  output;
  end;

run;

/* output from above is integer values 1,...,8 */ /* to show results with labels */ proc format; value hebrew

 1 = "Aleph"
 2 = "Beth"
 3 = "Gimel"
 4 = "Daleth"
 5 = "He"
 6 = "Waw"
 7 = "Zayin"
 8 = "Heth";

run;

/* check results */ proc freq data = test; tables x; format x hebrew.; run;



J solution

Well done, TBH.

--DanBron 22:44, 24 December 2008 (UTC)

Thanks, Dan. As I'm sure you recognized, the local definitions are simply for improving readability. In particular, the one for partitions (prtn) exists only to document and emphasize the partition-set that is the left argument to Interval Index. Omitting that name would still keep things simple and readable: da=. (+/\pt) I. ?y # 0
--TBH 18:55, 25 December 2008 (UTC)

TBH I don't know if it's worth it, but another possib. for counting is: pa =. \:~ y%~ #/.~ da

--Gaaijz 18:41, 26 December 2008 (UTC)
The problem I see with this is that it operates on the assumption that the actual proportions will fit the target proportions. This is to be tested, so cannot be assumed. The flaw is most clear when very small runs occur, in which cases the actual proportions are usually not in the same order as the targets. In such cases the code proposed above will pair proportions inaccurately. Nevertheless, I do appreciate being reminded of reflexive keyed-copy. --TBH 19:18, 27 December 2008 (UTC)

Convergence

This task might be more interesting if the measured probabilities were displayed every (log n) runs (i.e. at 10, 100, 1000, etc.), to show the rate of convergence towards the expected hit ratio. --Michael Mol 02:37, 8 November 2009 (UTC)

"Random" vs. "Pseudorandom"

Not one solution on this page (at least among those that I have been able to read; I admit that J, for example, reads like Greek to me) uses actual random numbers. They all use pseudorandom numbers of one stripe or another. This distinction is more important than ever with the advent of actual random number services online (Random.org, LavaRnd, and HotBits, among others), one might reasonably take the task specification literally and mark every solution as incorrect. What I have done instead is to change the text of the task from "generate a million items randomly subject to" into "generate a million items randomly (or, more likely, pseudorandomly) subject to". I think this clarification makes things "right". Thoughts? --Balrog 17:25, 16 April 2011 (UTC)