jeudi 16 juin 2016

How to do random.randint with certain precentage?

Actually , I have tried to make a script to decide that :

Whether I can delete a positions from a list or not based on thresold value but I want to do the same with probability (certain percentage)

import random

Numbers=[1, 2,3,4,5]
threshold_value=0.5

samples= [ random.randint(1, 2) for x in mutations if x > threshold_value]
Delete = samples.count(1)
DontDelete = samples.count(2)

for s in samples:
    msg = 'Delete' if s==1 else 'DontDelete'
    print msg

Expected output :

If user give 50% .

It should find the positions that appeared 50% of time as a delete.

Also It should give the suggested deleted position.

Aucun commentaire:

Enregistrer un commentaire