dimanche 18 novembre 2018

Finding the probability of a variable in collection of lists

I have a selection of lists of variables

import numpy.random as npr 

w = [0.02, 0.03, 0.05, 0.07, 0.11, 0.13, 0.17]

x = 1

y = False

z = [0.12, 0.2, 0.25, 0.05, 0.08, 0.125, 0.175]

v = npr.choice(w, x, y, z)

I want to find the probability of the value V being a selection of variables eg; False or 0.12.

How do I do this. Heres what I've tried;

 import numpy.random as npr
import math 

w = [0.02, 0.03, 0.05, 0.07, 0.11, 0.13, 0.17]
x = 1
y = False
z = [0.12, 0.2, 0.25, 0.05, 0.08, 0.125, 0.175]

v = npr.choice(w, x, y, z)

from collections import Counter 
c = Counter(0.02, 0.03, 0.05, 0.07, 0.11, 0.13, 0.17,1,False,0.12, 0.2, 0.25, 0.05, 0.08, 0.125, 0.175)

def probability(0.12):
    return float(c[v]/len(w,x,y,z))

which I'm getting that 0.12 is an invalid syntax




Aucun commentaire:

Enregistrer un commentaire