Talk:One of n lines in a file: Difference between revisions

From Rosetta Code
Content added Content deleted
(→‎implicit constraints: There is enough to complete the task I think?)
Line 12: Line 12:


:My original reference talked about choosing lines from a file, hence the title. The algorithm may be of use elsewhere (thanks for your suggestion Ledrug), but unless this algorithm has another name by which it is more commonly known, then I would like to leave the name as it is, rather than thinking up a new name that may only be of used on RC (rather than RC and StackOverflow :)<br><br> --[[User:Paddy3118|Paddy3118]] 21:43, 14 September 2011 (UTC)
:My original reference talked about choosing lines from a file, hence the title. The algorithm may be of use elsewhere (thanks for your suggestion Ledrug), but unless this algorithm has another name by which it is more commonly known, then I would like to leave the name as it is, rather than thinking up a new name that may only be of used on RC (rather than RC and StackOverflow :)<br><br> --[[User:Paddy3118|Paddy3118]] 21:43, 14 September 2011 (UTC)

==Simulation==
Please note that the actual task just asks for the results of a simulation of the algorithm. You can use mock files ''or not''. Although the explanation of the algorithm mentions files, the task doesn't ''require'' file handling. Thanks. --[[User:Paddy3118|Paddy3118]] 21:54, 14 September 2011 (UTC)

Revision as of 21:54, 14 September 2011

Inspiration

I read this and thought of RC. --Paddy3118 22:03, 7 September 2011 (UTC)

implicit constraints

I believe that this task implicitly assumes that a single line will always be small enough to be kept in memory? If so, I think that this assumption should be explicitly stated. (It sounds silly, but it can turn into a real issue.) --Rdm 20:19, 14 September 2011 (UTC)

Choosing a random item from a sequence of unknown length has its uses other than reading files. Actually since the task doesn't ask anyone to read a file anyway, shouldn't it be named something else like, er, "Choosing a random item from a sequence of unknown length"? --Ledrug 20:36, 14 September 2011 (UTC)

I don't know whether it's worth noting or not, but there will be issues relating to precision in implementations' real, non-integer numeric types and with precision in its random number generator. --Michael Mol 21:18, 14 September 2011 (UTC)

The central idea is to show the algorithm and to show that it gives approximately the right frequency of choice of each line for an example. Yes, if you were to use it in earnest then you would need to measure the limits of the environment you put it in. If you never have files of more than X lines then you can work out what numerical precisions you need. Put a limit on the maximum length of a line of a file then you can begin to think of memory constraints. Thing is, that is something that anyone using RC code in production should be doing anyway. I would not want to add a comment about line lengths to the task for that reason.
My original reference talked about choosing lines from a file, hence the title. The algorithm may be of use elsewhere (thanks for your suggestion Ledrug), but unless this algorithm has another name by which it is more commonly known, then I would like to leave the name as it is, rather than thinking up a new name that may only be of used on RC (rather than RC and StackOverflow :)

--Paddy3118 21:43, 14 September 2011 (UTC)

Simulation

Please note that the actual task just asks for the results of a simulation of the algorithm. You can use mock files or not. Although the explanation of the algorithm mentions files, the task doesn't require file handling. Thanks. --Paddy3118 21:54, 14 September 2011 (UTC)