Random Articles Generator - Articles Order

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Random Articles Generator - Articles Order

Tal Barda
Hi! 
I have a question regarding the random articles generation in the API.
Let's say I'm using this URL to retrieve two random articles: 


I got an API response which contains articles A and B in this order:
1. A
2. B

Is there a chance (I know it's very small, but it's just for my understanding), that I'll get the exact articles but in the opposite order? Like this:
1. B
2. A

I'd like to know whether there is certain order for the random articles in the API response, or it's also random. 

Thanks!





_______________________________________________
Mediawiki-api mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
Reply | Threaded
Open this post in threaded view
|

Re: Random Articles Generator - Articles Order

Brian Wolff


On Sunday, March 18, 2018, Tal Barda <[hidden email]> wrote:

> Hi! 
> I have a question regarding the random articles generation in the API.
> Let's say I'm using this URL to retrieve two random articles: 
> https://en.wikipedia.org/w/api.php?format=xml&action=query&generator=random&grnlimit=2&grnnamespace=0
> I got an API response which contains articles A and B in this order:
> 1. A
> 2. B
> Is there a chance (I know it's very small, but it's just for my understanding), that I'll get the exact articles but in the opposite order? Like this:
> 1. B
> 2. A
> I'd like to know whether there is certain order for the random articles in the API response, or it's also random. 
> Thanks!
>
>
>
>

Only if there is only 2 articles in wiki.

There is a deterministic "random" order of pages (on creation, each page is associated with a random number). The random api module picks a random place in this ordering to start, and then returns results in order of their random number.

--
brian
_______________________________________________
Mediawiki-api mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
Reply | Threaded
Open this post in threaded view
|

Re: Random Articles Generator - Articles Order

Betacommand
In reply to this post by Tal Barda
If I recall correctly the "randomness" is predetermined and you are always going to pull from the same list order but in random location on said list. This is from memory so take it with a grain of salt

On Sun, Mar 18, 2018 at 4:55 PM Tal Barda <[hidden email]> wrote:
Hi! 
I have a question regarding the random articles generation in the API.
Let's say I'm using this URL to retrieve two random articles: 


I got an API response which contains articles A and B in this order:
1. A
2. B

Is there a chance (I know it's very small, but it's just for my understanding), that I'll get the exact articles but in the opposite order? Like this:
1. B
2. A

I'd like to know whether there is certain order for the random articles in the API response, or it's also random. 

Thanks!




_______________________________________________
Mediawiki-api mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api

_______________________________________________
Mediawiki-api mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
Reply | Threaded
Open this post in threaded view
|

Re: Random Articles Generator - Articles Order

Platonides
As mentioned, the order of the random articles should be stable... Assuming that there are no changes on the wiki affecting that. Article creations, deletions, etc. means that the articles on your list could disappear, and reappear somewhere else, as well as new ones appearing between them. As an extreme example, if you renamed each page to the title of the other, you would get a list of the same articles in the opposite order.

Best regards


_______________________________________________
Mediawiki-api mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api