A playlist contains 10 rock songs, 3 country songs, 5 R&B songs, and 2 blues songs - probability

enter image description hereA playlist contains 10 rock songs, 3 country songs, 5 R&B songs, and 2 blues songs. In shuffle mode, each song is played exactly once, and all possible equal orderings are equally likely. Suppose that a person starts this playlist in shuffle mode and continues until a country music song plays, and then stops. Let denote the number of songs played before the country music song (but not including the country music song itself). [[Hint: Write , where if the th non-country song is played before all of the country songs, or otherwise.]]
In this task (attached)it is necessary to find variance, solution is attached enter image description here,but I do not understand why we multiply by 2 when finding E[Xi*Xj]
Why we multiply by 2?? And also how we got 1/4*1/5 - appreciate some explanation.

Related

how to create schedule of championship?

My english is not very well, but i try to explain.
I must create a schedule for championship. We have 8 players. They play in one league. THeir will be 7 tournaments played in cup system. So, every player will be play with every player, and it's not problem:
schedule
I want to every player when he goes to semifinals play with every player two times (assuming they get promoted to semifinals). So player number one must play ones in quaterfinal with player 2, and two times when he get promoted to semifinals.

Sorting sets Q of a set S such, that all members are represented biased on S (shuffling music titles of different artists within a directory)

Starting position:
My wife has a collection of music titles stored on her walkman. The files are all stored in a single directory, with the help of a tool I wrote plus some manual assistance, in the format
Artist1 - Title1
Artist1 - Title2
...
Artist1 - TitleN
Artist2 - Title1
...
ArtistM - TitleZ
Some artists have just as few as a handful titles (one featuring just 1 title), while others sport as many as 56 titles. All in all, the growing collection encompasses a 4-digits number of n titles now (about 1200).
These titles are all sorted alphabetically within that single directory, so that a title can be found quite easily, mainly for the purpose of removing a now disliked title from the collection.
This said, it should be obvious, that this collection is to be played randomly, using the walkman's built-in shuffle mode.
Problem:
The shuffle mode of this walkman is really not worth being called this way.
It is quite common, that songs from the same artist (stored sequentially in the folder) are played consecutively, not rarely even 3 of them in a row. This behaviour certainly is not perceived as "random".
Approach:
My approach was to pre-shuffle these titles programmatically, to be played sequentially. The strategy was to ensure, that an artist does not play 2 of her songs in a row.
For this I let my program evaluate for each artist the number of titles present, to determine the artist with the most titles, and found m=56. From that number I programmatically find the next prime p=59.
Now the idea was to iterate through the original alphabetically sorted list in a step width of n mod p, so that eventually all titles get copied in a way that they don't expose two consecutive titles of the same artist.
This works as expected.
However, after about n/p (currently about 30) titles, the artists repeat (with different titles, but still giving the impression "just heard her"), while many other artists featuring less than m titles are quite never played.
Question:
Is there a mathematical approach to improve my psychologically quite trivial approach to play as many titles from different artists as possible before playing an arbitrary other one of her titles (even at the expense of playing underrepresented artists more often), other than just trivially keeping track of every artist's already copied title and duplicating titles in the play list?

Complex pairing algorithm - team tournament

I would like to ask for help with an algorithm I’ve been working on for quite some time. I actually programmed it a few years ago using greedy pairing mostly but I’m not satisfied. Any help would be greatly appreciated!
So getting down to business. I have an application for tournament play (beachvolleyball to be precise, but should work for any pair-sport played in tournament format). The players show up on tournament day and gets randomly-ish put together with other participants and against other random teams. Top focus is to play as much as possible, however the number of players aren’t always divisible by the number of simultaneous playing spots. Therefor there will always be a number of players resting, standing the round out that is, and I’m trying to make sure this is as fair as possible by using 2 variables:
Rests (total number of rests during the day)
Rests in a row (Resting several games in a row, obviously)
The original concept of the tournament was mixing the teams with 1 male(m) and 1 female(f) in each team, playing against another team of m/f. However, the resting part is more important and there is often a lot more players of one sex than the other (i.e. 20 f and 7 m). Instead of letting the males play every single round, the program should make teams of f/f playing against f/f. Same-sex vs f/m should be avoided though.
Players should get new partners every round and play against new teams every round. Preferably you should play with all players of the opposite sex before playing with someone again. Players are allowed to come and leave as they like, and also take a break at any time (voluntary rest).
I’ve looked into the unstable marriage problem and the roommate problem, but my problem seems to be a mix of the two. Normally there will be two lists of players (m/f) and pairing, but under certain premises there should be teams made from just one list as described. Let me give you an example:
EXAMPLE:
43 players show up for a tournament with 6 courts.
17 Females (f) and 26 Males (m).
The 6 courts fit 12 teams with a total of 24 players per round.
Round 1
*12 m - 12 f*
*19 resting (5f, 14m)*
Round 2
5f and 14m have 1 rest and should play.
The best solution would be:
*4 f - 4 m*
*1f - 1m*
*4m - 4m*
*1f - 1m* (these players played last round as well).
In this example there will normally not be more than 1 rests in a row, if there woud’ve been 49 players from the start on the other hand..
In future updates, I’m also planning on letting the user choose number of players per team, and also to skip the m/f requisite.
Any thoughts?

Shuffle Groups algorithm

I need a "shuffle albums" algorithm for my audio player like in foobar2k. So the problem is: I have a list of tracks, sorted according to some criteria so that tracks with same album are all adjacent. Now I need to be able to play songs from the playlist in "shuffle albums" mode, that is, if the next track is from the same album, just play it, otherwise, go to the first track of a next random album. If the user wants to play previous track, do the same thing but backwards. So the question is: how do I know what previous album was? I really don't want to keep a history of played albums, or keep a separate list.
Currently, I implement regular shuffle mode by giving each track random shuffle index, so that I can find previous and next tracks by finding tracks with largest shuffle index smaller than current and smallest shuffle index larger than current. But it doesn't work for shuffle albums mode. Can somebody help me with this?
Sample input:
Track 1, Album A
Track 2, Album A
Track 1, Album B
Track 2, Album B
Track 3, Album B
Track 1, Album C
Track 2, Album C
Track 3, Album C
Let's say current track is Track 1, Album A. Next track will be Track 2, Album A. Next track is not from the same album, so a first track from a random album should be chosen, let's say, Track 1, Album C. What I'm doing now is choosing next track as if it was regular shuffle mode, then going to the first track of its album, thus loosing information from where I came to this album. SO when the user wants to go to the previous album, I have no information how I got there. Hope that makes the question clearer.
Thank you.
You can reuse your shuffle index technique to index albums. Now a track index is an (album shuffle index, track pos) pair. To navigate, increment / decrement the track pos; if it goes out of bounds, update the album index.
That said, you should reconsider not keeping an history; it would let you skip back much faster with a large number of albums.

Sorting A List Of Songs By Popularity

For student council this year, I'm on the "songs" committee, we pick the songs. Unfortunately, the kids at the dances always end up hating some of the stupid song choices. I thought I could make it different this year. Last thursday, I created a simple PHP application so kids could submit songs into the database, supplying a song name, artist, and genre (from a drop-down). I also implemented a voting feature similar to Reddit's. Click an upvote button, you've upvoted the song, incremented the upvote count. Same with downvotes.
Anywho, in the database, I have three tidbits of information I thought I could use to rate these songs, upvotes, downvotes, and a timestamp. For a while, the rank was created by simply having the songs with the higher "vote" count at the top. That is, the more upvotes, less downvotes (upvotes - downvotes) would be at the top of the list. That worked, for a while, but there were about 75 songs on the list by Sunday, and the songs that were submitted first were simply at the top of the list.
Sunday, I changed the rank algorithm to (upvotes - downvotes) / (CurrentTimestamp - CreationTimestamp), that is, the higher the vote count in the lesser amount of time, the higher the song would be on the list. This works, better, but still not how i'd like it.
What happens now, is that the instant a song is created and upvoted to a vote count of 1, it ends up at the top of the list somewhere. Songs who have vote counts in the negatives aren't viewed often because kids don't usually scroll to the bottom.
I guess I could sort the data so the lower songs appear at the top, so people are forced to see the lower songs. Honestly, I've never had to work on a "popularity" algorithm before, so, what are your thoughts?
Website's at http://www.songs.taphappysoftware.com - I don't know if I should put this here or not, might cause some unwanted songs at the dance :0
That's a very good question. There are a few similar questions that have been asked here.
This article is probably a good place to start. Apparently upvotes minus downvotes is a bad way to do it. The better way is to use complicated maths to assign a score to each and sort by that.
Here is a scoring function in Ruby from the article:
require 'statistics2'
def ci_lower_bound(pos, n, power)
if n == 0
return 0
end
z = Statistics2.pnormaldist(1-power/2)
phat = 1.0*pos/n
(phat + z*z/(2*n) - z * Math.sqrt((phat*(1-phat)+z*z/(4*n))/n))/(1+z*z/n)
end
pos is the number of positive
rating, n is the total number of
ratings, and power refers to the
statistical power: pick 0.10 to have a
95% chance that your lower bound is
correct, 0.05 to have a 97.5% chance,
etc.
As a usability thing, I would sort the data by the score, but I would not show the score to the user. I would only show the number of upvotes and downvotes.
How about sorting songs by posting time or number of votes (negative + positive)? If your goal is to give every song equal attention, this sounds good enough.

Resources