Thursday, 29 June 2017

To Maximize the Probability of Red Marble

You have 50 red balls and 50 blue balls, you have to place these balls in two containers in such a way that probability of a person picking up a red ball from any container is maximum.

1. For container 1,
You should have to place one red marble into 1st Container. By this when we select this Container 1 P(Red|C1) will be 1.

2.  For container 2,
Rest all marbles should have to place into 2nd container. By this when we select this Container 2 P(Red|C2) will be 49/99.

Here, P(C1) = P(C2) = 1/2 as there is only 2 containers.

So answer will be P(Red) = P(C1)*P(Red|C1) + P(C2)*(Red|C2)
                                                  P(Red) = (1/2)*(1) + (1/2)*(49/99)
                                                  P(Red) = 0.747474.

Proof of above given solution using the Java code:
public class MaximizeRedBallProbability {
     /**
      * This is the code which maximize the probability.
      * @param red
      * @param blue
      * @return probability
      */
     private static double getProbability(int red, int blue) {
           double max=0;
           int maxRed = 0;
           int maxBlue = 0;
          
           for (int i = 1; i < red; i++) {
                for (int j = 0; j < blue; j++) {
                     double prb = (0.5*i)/(i+j) + (0.5*(50-i))/(100-i-j);
                    
                     if (prb>max) {
                           max = prb;
                       maxRed=i;
                       maxBlue=j;
                     }
                }
           }
           System.out.println("Container 1, Red balls: "+maxRed +" Blue balls : "+maxBlue);
           System.out.println("Container 2, Red balls: "+(red-maxRed) +" Blue balls : "+(blue-maxBlue));
           return max;
     }
    
     /** Driver Method. */
     public static void main(String[] args) {
           int red = 50;
           int blue = 50;
           double p = getProbability(red,blue);
           System.out.println("Maximum probability of RED ball "+p);
     }
}
Output: 7474747474747475

                                                  

17 comments:

  1. Welcome to Ragdoll Kittens Cattery click here to adopt a ragdoll

    kitten online
    We are a small and loving cattery . We are pleased that you have chosen to visit our Ragdoll

    cats/Ragdoll kittens cattery, and hope you will notice right away from our website how beautiful and loved our

    Ragdoll cats and kittens are. These beauties are easily integrated into our loving family home, first as

    mothers carrying the litters, and then from the time the ragdoll kittens are born until they are adopted so we

    always have Ragdoll kittens for sale|Ragdoll kittens for adoption|Ragdoll kitten price|Ragdolls|Cost of Ragdoll

    kittens|. Our adult cats have tested negative for HCM and PKD1 through University of California Davis. Upon

    request, we have five generations of pedigree documentation on our adults available to anyone who is

    interested. Ragdoll kittens are registered with The International Cat Association (RAGDOLL KITTENS FOR SALE),and are never caged. The cats that are

    in our reputable breeding program can produce mink, sepia and traditional Ragdoll kittens. Ragdolls have a

    laid-back personality and enjoy being physically handled making them one of the best lap cats! We are all

    family here at Ragdoll kittens cattery since we are ragdoll kitten breeders and all the love we bestow by

    holding each cat and kitten daily further Teacup RAGDOLL Kittens

    for sale|Hypoallergenic kittens for sale
    nurtures their loving personalities and temperaments,TICA/CFA REGISTERED RAGDOLL KITTENS FOR SALE thanks for adopting a

    ragdoll ketten from us

    Welcome to our farm where we breed Registered pomeranian puppies

    for sale
    .As a registered pomeranian puppies breeder, we have made it possible for pomeranian puppy lovers

    to
    buy pomeranian puppies online,buy zwergpitz pomeranian from our family run farm. Pomeranian

    dogs are small dogs with a weight of 1.36 to 3.17 kg and a withers height of 15 to 18 cm. They are compact but

    robust dogs with a lush, textured coat and a tall and flat tail. The top coat forms a fur ruff on the neck, for

    which poms are known, and on the hindquarters they have a margin of feathered hair.You can click HERE to view our available pomeranian puppies

    ReplyDelete
  2. Thanks for this. I really appreciate your good work

    ReplyDelete
  3. Buy medical marijuana online at [url=https://medicanabudshop.com] The Best Bud Shop [/url]

    ReplyDelete
  4. Thanks for this. I really appreciate your good work

    ReplyDelete
  5. nothing is so meaningful. like reading a good content

    ReplyDelete
  6. Wow. This is truly an amazing post. Thanks for sharing.

    Buy Custom Website

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...