Probability of obtaining 2 hearts and 2 aces - combinations

I am really really struggling with this question and so far have not found an answer nor could figure it out correctly. I'll really appreciate if anybody can help answering the question with explanations. Thanks in advance!
You are to pick 4 cards randomly from a deck of cards that contains four suits and the following denominations: Ace, 2, 3, 4, 5, 6, 7, 8, 9, and 10.
There are no face-cards in this deck. "What is the probability of obtaining two Aces AND 2 hearts"?

Related

ml.net Predict an outcome using historical data

I am a complete to newbie to machine learning but I am trying to achieve following:
I have a series of data, let's say:
ie:
[ {'day1', 5}, {'day2', 3}, {'day3', 8} ... {'day100', 8}]
that at the end has a final result:
ie: pass/fail/other result
I would like to predict the most likely end result by using a partial set of data
ie: [{'day1', 3}, {'day2', 1}, {'day3', 6} ... {'day50', 8}]
What would be the best way to achieve this and if possible, do you have any examples or hint of where to look into that could help someone like me with no experience in machine learning
It is a time series prediction.
I'd suggest you check if your time series contain trend or seasonality. Then try conventional methods of time-series prediction as moving average (or sliding window) when you, for example, predict day 6 based on days 1-5, then day 7 based on days 2-6 etc. You may also try Exponential Smoothing and ARIMA.
Concerning ml.net, the following tutorial is the best solution for you
as it uses a Singular Spectrum Analysis and thus takes into consideration a trend and possible seasonality to forecast values. You can employ it by using
ssaforecastingestimator: put window = 25 and horizon=1 if you want to use the first 25 days to predict the value for day 26 (prediction one step forward). I suggest you take a smaller window though (5-7 days).

Maximum children happiness [duplicate]

This question already has answers here:
How to code the maximum set packing algorithm?
(2 answers)
Closed 8 years ago.
Given N different candies and M children. Each of the children demands for K[i] different candies and will only be happy iff he get all those different candies which he demanded.
Now I want to maximize the number children that get happy. How should I distribute the candies?
Example: Let's have N=4 candies and M=3 children:
1st child requires 2 (K[1]) candies which are: 1 and 2
2nd child requires 2 (K[2]) candies which are: 2 and 3
3rd child requires 2 (K[3]) candies which are: 3 and 4
The answer here is 2 as I can at best only make the 1st and 3rd child happy.
My attempt:
Give candies to children in the order of the amounts that they require to be happy (i.e. K[i]). In other words, you should only give candy to a child if you have made happy all the children that demand less, and every time you give candy to one of them you have to give them the whole amount that they require.
Is this solution correct?
Yes, you are wrong. Consider:
Wants candies 1, 2, 3, and 4.
Wants candies 1, 5, 6, 7, 8, and 9.
Wants candies 2, 10, 11, 12, 13, 14, and 15.
Wants candies 3, 16, 17, 18, 19, 20, and 21.
Wants candies 4, 22, 23, 24, 25, 26, and 27.
Your algorithm will only make child 1 happy. But you can make 2, 3, 4, and 5 happy.
As this a problem in on-going programming contest i cannot give you much of an answer but will push you in right direction. The problem you are solving is np complete as it can be reduced to maximum independent set and hence it can only be solved in general case using brute force which is trying out all combinations. You can reduce computations by checking if new set added is not intersecting with the other in this way you can skip a lot of invalid combinations.

Genetic algorithm in univeristy timetabling

Can anybody help me understand how to apply a GA in timetabling?
Right now I understand the steps of a GA, but don't know how to implement them in my project.
Can somebody guide me? If there is any pseudocode or links to help me it will be very much appreciated.
This is my university project. I'm not asking for working code, just some idea n pseudocode on how to implement it.
Thanks in advance!
Take a look at Solving Timetable Problem by Genetic Algorithm and Heuristic Search Case Study: Universitas Pelita Harapan Timetable
Transform the problem into a integer representation using an array to represent the chromosomes in the population.
Example {1, 2 , 5, 3, 4, 6, 7, 5}
The index in the array represents courses and the number at each index represents the time slot that the course is assigned to on a day. Random populations can then be created and evaluated based on a fitness function that would take into consideration the students associated with each course, course size, and any other constraint that may be present. I have used this approach to solving a university final examination timetable and it has worked well.

SML: Filtering list non-recursively

I'm trying to filter a list non-recursively but I'm not sure how to go about going it.
For a simple example, say I have a list [1, 2, 3, 4, 5, 6, 7] and I want to filter it so it returns a list of numbers greater than 3, ie [4, 5, 6, 7].
I can do it recursively no problem but I'm stuck here. Unfortunately, I'm new to sml and the best I can think of is using map but I don't think map was made for this.
You're right: map wasn't made for this - the list produced by map will always have the same size as the list given to map.
List.filter however was made for this. If you call List.filter with a function as an argument that returns true if a number is greater than 3, it will do exactly what you want.
Hint: try it using foldr, not map.

Two plus Two Poker hand evaluator: How are the cards mapped to the integers?

In an effort to create the fastest possible monte carlo texas hold'em hand analyzer with C++, I am currently looking into the subject of hand evaluation.
As many of you may know, there are quite a number of hand evaluators, open source, out there. After giving it some thought, I settled on the "Two Plus Two hand evaluator" (so named since it was first introduced on the two plus two forum).
This is one of the fastest known evaluators out there, and uses array lookups to quickly find the value of a hand.
Now, for the function, you need to pass in an array with the cards you are interested in. Example:
int Cards[] = { 3, 5, 10, 17, 23, 24, 32 };
int hv = HandValue(Cards);
With values between 1 and 52. Now, my question is: What cards do these integers correspond to? Is a 3 an ace of spades? A three of hearts? I have scoured google, the two + two forum, various pages where hand evaluators are presented, the source file for the build-up of the array. All in vain. So I am hoping that someone here can point me in the right direction of where I can find this information, or give it to me outright.
The source where the evaluators are taken from is this excellent article: http://www.codingthewheel.com/archives/poker-hand-evaluator-roundup#cactus_kev
Which explains all the evaluators individually.
I didn't verify this, but it appears to be:
"2c": 1,
"2d": 2,
"2h": 3,
"2s": 4,
"3c": 5,
"3d": 6,
...
"kh": 47,
"ks": 48,
"ac": 49,
"ad": 50,
"ah": 51,
"as": 52
ref: https://github.com/chenosaurus/poker-evaluator/blob/master/lib/PokerEvaluator.js