Timeline for What is a readable algorithm for selecting a random buyer based on what they purchased?
Current License: CC BY-SA 3.0
12 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| May 23, 2017 at 12:40 | history | edited | CommunityBot | replaced http://stackoverflow.com/ with https://stackoverflow.com/ | |
| Oct 12, 2015 at 7:33 | comment | added | Parham Doustdar | I still learned a lot from your answer. Upvote for that. Thank you both; you're awesome. | |
| Oct 11, 2015 at 16:00 | history | edited | Mike Nakis | CC BY-SA 3.0 | added 92 characters in body |
| Oct 11, 2015 at 15:59 | comment | added | Mike Nakis | @scriptin I see. You are right. Thanks for clarifying with the OP, and thanks for going to great length to explain it to me. I am sorry for not having spent the time myself to figure it out on my own. | |
| Oct 11, 2015 at 15:43 | comment | added | scriptin | As author explained, each score point is a ticket in a "lottery", and your algorithm makes that lottery unfair, since not all tickets participate. All tickets must have a chance, it's just a matter of which one is selected in the end. Since each purchase can have more than one score, you can imagine that as buying few tickets in a row, multiplying your chances to win by the number of tickets you buy. | |
| Oct 11, 2015 at 15:39 | comment | added | scriptin | Yes, it is. But still that's just random selection with a threshold filter: 1) items which are not in top N do not get a chance to be selected, 2) items among those top N are selected randomly, without considering the score. You're using the score only as a threshold. I asked a question about that in a comment, and author replied that indeed he wanted to implement fitness proportionate selection (with a single round of selection). I'm not saying your algorithm is wrong, but it's different, and it's not what the question is about. | |
| Oct 11, 2015 at 13:46 | comment | added | Mike Nakis | @scriptin but I say "Use SUM() to calculate total points per customer", and then "Use ORDER BY on the sum of points" and then "Use `LIMIT 60 to select someone among the top 60". The sum of points is, you know, the score. No? | |
| Oct 11, 2015 at 13:24 | comment | added | scriptin | I believe your approach is correct (doing everything in SQL), but you're describing another algorithm. Particularly, score is not even taken into account - you only filter top N records by score, but after that you just select randomly, i.e. with even distribution, which conflicts with question's intent. | |
| Oct 11, 2015 at 13:07 | history | edited | Mike Nakis | CC BY-SA 3.0 | added 141 characters in body |
| Oct 11, 2015 at 10:05 | history | edited | Mike Nakis | CC BY-SA 3.0 | added 41 characters in body |
| Oct 11, 2015 at 9:59 | history | edited | Mike Nakis | CC BY-SA 3.0 | added 41 characters in body |
| Oct 11, 2015 at 9:53 | history | answered | Mike Nakis | CC BY-SA 3.0 |