Roulette selection

1.3k Views Asked by At

i'm using roulette selection algorithm for android using the code bellow :

//int n=4;
//double [] weight = new double [n];
//weight[0]=9;
//weight[1]=8;
//weight[2]=10;
//weight[3]=1;
public void Roulette(double weight[],double max_weight){
    int index=0;
    while (true){
        index= (int)(weight.length*Math.random());
        if(Math.random()<weight[index]/max_weight) {break;}
    }
    Toast.makeText(getBaseContext(),"Chosen="+index,Toast.LENGTH_LONG).show();
}

is it possible to create (graphique and code) something like showed in the figure bellow using android studio ?

enter image description here

1

There are 1 best solutions below

2
godot On

You can use some charts for android, for example this: MPAndroidChart