python - percentiles from counts of values -


I want to calculate in Python with a detachment of multiple large vectors. Instead of adding vectors and then trying to insert the resulting vector, is there a more efficient way?

My idea will be first, the frequency of different values ​​(using the example), secondly, combining those item frequencies for different vectors, and finally, calculations of counterparts from calculations.

Unfortunately I can not find the function for the combination of frequency tables (this is not very easy, because different tables can cover different items), or calculate antithesis from an item frequency table. for. Do I need to implement them, or can I use existing Python functions? What will happen to those tasks?

Using the collections.Counter to resolve the problem first ( Calculation of the calculation and frequency tables) After the suggestion of Julian Palard, and my implementation for the second problem (Calculation of percentage from frequency tables):

  Import countercf calc_percentiles from the collection (cnts_dict, percentiles_to_calc = Range (101): "Return" [(percentile, value)] percentile with the nearest rank percentile: 0:. & Lt; MIN_VALUE & gt;, 100: & lt; MAX_VALUE & gt; cnts_dict: {& Lt; value & gt ;: & lt; count & gt;} percentiles_to_calc: to calculate the iterable percentile; 0 & lt; = ~ & lt; = 100 "" "emphasis is all (0 & lt; = P <= 100 percentiles_to_calc for P) percentile = [] num = amount (cnts_dict.values ​​()) CNTs = accordingly (cnts_dict.items ()) curr_cnts_pos = 0 # current condition in CNTs curr_pos = CNTs [0] [1] current_cnts_pos was sorted for freqs # of the above #pip (percentiles_to_calc): If P & lt; 100: percentile_pos = p / 100.0 * num while curr_pos & lt; = Percentile_pos and curr_cnts_pos & lt; Lane (CNTs): curr_cnts_pos + = 1 curr_pos + = CNTs [curr_cnts_pos] [1] percentiles.append ((P, CNTs [curr_cnts_pos] [0]) and: percentiles.append ((P, CNTs [-1] [ 0])) # We can add a small value refund counter to the segment_iterator section in percentage cnts_dict = (): cnts_dict + = counter (segment) percentile = calc_percentiles (cnts_dict)  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -