Este es un seguimiento de esta pregunta, ya que creo que he podido simplificar el objetivo: 3x3 Scratch and Win
Suponga que tiene una bolsa con
Suponga que elige bolas una por una (y las devuelve después a la bolsa, por lo que la probabilidad de obtener una bola roja/negra nunca cambia).
Si un usuario saca al azar una pelota de la bolsa 9 veces:
Supongamos que tenemos bolas rojas y bolas negras Entonces la probabilidad de sacar una bola roja es y la probabilidad de sacar una bola negra es . Dejar , y definir para . Dejar ser un entero no negativo y un entero positivo. Entonces
Solo si alguien está interesado, siguiendo a @lioness99a y @NF Taussig responde:
import org.apache.commons.math3.distribution.BinomialDistribution;
public class ScratchAndWin {
public static void main(String[] args) {
double PROBABILITY_RED = 0.10; // <--- change this
int EXTRACTIONS = 9;
int REQUIRED_SUCCESSES = 3;
BinomialDistribution distribution = new BinomialDistribution(EXTRACTIONS, PROBABILITY_RED);
double percentaje = 1 - distribution.cumulativeProbability(REQUIRED_SUCCESSES - 1);
System.out.println("PERCENTAGE WINNERS 3 REDS: " + percentaje);
}
}
leona99a
NF Taussig
pelyadolfo
pelyadolfo