Talk:Probabilistic choice

From Rosetta Code
Revision as of 19:08, 19 December 2009 by 24.62.203.42 (talk)

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)