Did I find the right examples for you? yes no

All Samples(6)  |  Call(4)  |  Derive(0)  |  Import(2)

        def weighted_avg(vals, weights):
    return sum([v*w for v,w in zip(vals,weights)]) / sum(weights)
        


src/s/o/sotumachine-HEAD/speechgen/models.py   sotumachine(Download)
from settings import LANG_MODEL_DIR
 
from utils import num_wiggle, parse_weight_string, weighted_avg, join_dicts, retokenize, make_model_fname
 
class President(object):
                    self.stat_table['id']])
            if sum(weights):
                w_avg = weighted_avg(self.stat_table[key], weights)
                self.speech_stats[key] = w_avg
 

src/s/o/sotumachine-HEAD/speechgen/train_all_presidents.py   sotumachine(Download)
 
from settings import TEXT_DIR, LANG_MODEL_DIR
from utils import weighted_avg, make_model_fname
 
presidents = {
                speech_lengths[para_count] += 1
        stat_dict.update({
            u'avg_speech_length' : weighted_avg(speech_lengths.keys(),
                speech_lengths.values()),
            u'avg_para_length' : weighted_avg(para_lengths.keys(),
                para_lengths.values()),
            u'avg_sent_length' : weighted_avg(sent_lengths.keys(),