4

When I try to post my question, the interface tells me

Your post appears to contain code that is not properly formatted as code.

However, my post does not contain any code. How can I promise that there is no code, and post anyway?

Here is the post I'd like to make....

I want to generate an ordered sequence of finitely many random integers in a range such that any N-element subset (having no duplicates) of [b,e] is equally likely.

To do this I can of course just generate the N integers, then sort the them into increasing order. But is there a way to do this without having to sort? I.e., can it be done by selecting the smallest one first, and continuing in order.

First select r(0) in the range [b,e-N], then select r(1) in the range [r(0)+1,e-N+1], ... selecting r(k) in the range [r(k-1)+1,e-N+k].

There an obvious problems with this approach. If r(k) is blindly chosen in [r(k-1)+1,e] the resulting distribution will be heavily weighted toward the right. E.g., a sequence containing b and b+1 would be very unlikely.

Any suggestions?

13
  • 5
    What is it that you're posting that might look like code? You can't just skip the validation. That'd make the validator a little pointless.
    – Cerbrus
    Nov 15, 2017 at 15:24
  • 3
    Questions without code, although possible, are likely not on-topic questions. The site may be protecting you from a bad first user experience. Did you read the help center on what are on-topic questions?
    – Gimby
    Nov 15, 2017 at 15:30
  • Edit your question here with the contents of the question you want to post. If it fails to post here too, take a screenshot and post that.
    – Mat
    Nov 15, 2017 at 15:39
  • How can I show you what my post is without being able to post it? I'll try to post it into this comment.
    – Jim Newton
    Nov 15, 2017 at 15:41
  • No, I cannot post it into a comment, as it is 192 characters to long.
    – Jim Newton
    Nov 15, 2017 at 15:41
  • edit and add it to the bottom of your question.
    – user1228
    Nov 15, 2017 at 15:43
  • Here is a google-drive link to the content of the post I'd like to submit. drive.google.com/open?id=1jl8UziTJ6gkBfAWh7ZoM3DZIkbsu2nkD
    – Jim Newton
    Nov 15, 2017 at 15:43
  • 1
    OK, I've also added my intended text to the OP. Interesting that meta.stackoverflow does not have the same formatting requirements, otherwise it would still refuse to accept the text. :-)
    – Jim Newton
    Nov 15, 2017 at 15:47
  • It's Pseudocode you've added, it may be better to just format the Pseudocode as actual code. Nov 15, 2017 at 15:51
  • 1
    That question is too broad. How do you expect it to be answered?
    – Cerbrus
    Nov 15, 2017 at 15:51
  • How would I like it answered? I'd ideally like someone to suggest an algorithm for selecting r(k) as a function of N and r(0)...r(k-1) such that the finally selected sequence has the same probability of occurring as one that has been randomly selected and thereafter sorted.
    – Jim Newton
    Nov 15, 2017 at 15:55
  • If the question is about algorithm theory you should most definitely post it at cs.stackexchange.com .
    – Lundin
    Nov 15, 2017 at 16:03

1 Answer 1

10

Here's the naive pass as your question:

I want to generate X. Any suggestions?

Interpolating that into your question, this makes your question incredibly broad. It's not the worst thing in the world that the quality filter caught you from making a mistake by posting a question which wouldn't be well-received.

If we dig deeper into your question, it's fairly math-heavy. It doesn't feel like this is a problem that a software developer or engineer would face in their line of work, unless their line of work was very specialized. That's not to say that this is theoretical, but this doesn't feel like a practical programming problem, either.

My advice: don't post this question here. It's not going to get the answers it needs, or the attention it deserves. Computer Science or Math Stack Exchange may be better options, but don't feel gun-shy about asking on their Metas, either.

6
  • I posted it elsewhere: math.stackexchange.com/questions/2521621/…
    – Jim Newton
    Nov 15, 2017 at 16:04
  • 3
    Now I did say you should have asked on their Metas just to be sure that you would get a decent reception. Blindly trusting my advice that this is 100% the on-topic place wasn't the right thing to do...but here's hoping it gets received well.
    – Makoto
    Nov 15, 2017 at 16:05
  • 5
    'I tried to ask this question on stack overflow, but it was not well received. The suggestion was that I should ask it here.' - sure enough, one whisper of any sort of hint, and straight off, in the first sentence, is the shield. It's now SO's fault if the Q is off-topic on the target site:( We should not recommend migration sites, never mind do any actual migration! In this case, I suspect it's on-topic at math, but we will see.. Nov 15, 2017 at 16:26
  • Our daily meta-XY question.
    – Braiam
    Nov 15, 2017 at 17:27
  • The question seems to have already been asked. I haven't yet convinced myself that it has been answered. I'm still reading and trying to digest the answers. stackoverflow.com/questions/1866031/…
    – Jim Newton
    Nov 16, 2017 at 10:07
  • Martin, my comment about already having asked the question elsewhere was to guard against someone suggesting that such questions should be posed on stackoverflow instead, thus pre-avoiding the impending infinite loop.
    – Jim Newton
    Nov 16, 2017 at 10:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .