How to return result from ajax call synchronously?

If we don't know what algorithm is used to return a number, can we call it random?

  • Suppose there is a function which returns a number, and suppose we don't know what the function is and how it behaves: * it may be using a deterministic algorithm to return value. * or it may be just using rand() function to return a value. * or anything else. * but we don't exactly know what the function does, and we will never know. Then can we say that the value generated by the function is random for us? ****** real life problem ***** In a sql query when all the values are same the "order by" may present result in some order, and that order we can't know. Then can we say that the values will randomly ordered?

  • Answer:

    Yes and No. The output of a black box function, is completely random in the sense that output is unpredictable and cannot be known in either deterministic or probabilistic function. Now taking your real-life example, you can say that values will be randomly ordered but you can't make any claim about the properties of its randomness or qualify it i.e. you can't claim that there is no bias and probability of each value being at the top is equal. You don't know if the ordering is following a certain distribution. You can't make a deterministic/probabilistic estimation about the ordering. It may well be the same order, the values were inserted in. Another real-life example is the Multi-threaded applications where ordering of execution is indeterministic. 'Unknown' is a better term to use here than using the term 'random' as it may imply that probability of each ordering is equal. PS: This is completely my opinion. Hope to see answers with more insight.

Abhishek Agarwal at Quora Visit the source

Was this solution helpful to you?

Other answers

No it is not random, just the fact that you don't know the algorithm doesn't mean it is random, unless that is your definition of random, to start with you should apply some-tests to check that it is statistically random In your real life problem it is definitely not random, why would a output be randomized when it can be just plainly returned, it may depend on order of insertion.

Anurag Uniyal

For your SQL problem, your assumption is absolutely wrong. If you do 'order by' on 'same values', result set won't be random. It does have some order. According to me, it should be order of records in db(sorted by primary key/insertion time). Check your db and try it out. For random number query, technically its not random number if you don't know for sure. Whether you want to treat it as or not , depends on your requirement i.e. if your client application is ok with repeated numbers or not.

Pranalee Rokde

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.