EventsInformation And EventsCalculations

These two objects can get information from any Events class. Below the class docs are some code examples.

class dicetables.eventsinfo.EventsInformation(events: dicetables.eventsbases.integerevents.IntegerEvents)[source]
get_items()[source]
Returns

dict.items(): a list in py2 and an iterator in py3.

events_keys() → List[int][source]
events_range() → Tuple[int, int][source]
total_occurrences() → int[source]
all_events()[source]
all_events_include_zeroes()[source]
biggest_event() → Tuple[int, int][source]
Returns

(event, occurrences) for first event with highest occurrences

biggest_events_all() → List[Tuple[int, int]][source]
Returns

the list of all events that have biggest occurrence

get_event(event: int) → Tuple[int, int][source]
get_range_of_events(start: int, stop_before: int) → List[Tuple[int, int]][source]
class dicetables.eventsinfo.EventsCalculations(events: dicetables.eventsbases.integerevents.IntegerEvents, include_zeroes: bool = True)[source]
property include_zeroes
property info
mean() → float[source]
stddev(decimal_place=4) → float[source]
percentage_points() → List[Tuple[int, float]][source]

Very fast, but only good to ten decimal places.

percentage_points_exact() → List[Tuple[int, float]][source]
percentage_axes()[source]

Very fast, but only good to ten decimal places.

percentage_axes_exact()[source]
log10_points(log10_of_zero_value=- 100.0) → List[Tuple[int, float]][source]

returns log10 of the occurrences.

Parameters

log10_of_zero_value – any zero-occurrence must have a preset value.

log10_axes(log10_of_zero_value=- 100.0)[source]

returns log10 of the occurrences.

Parameters

log10_of_zero_value – any zero-occurrence must have a preset value.

full_table_string(shown_digits=4, max_power_for_commaed=6)[source]
Parameters
  • shown_digits – How many digits in each scientific notation string.

  • max_power_for_commaed – The largest power to be represented in comma notation. if set to -1, all numbers are in scientific notation.

stats_strings(query_list, shown_digits=4, max_power_for_commaed=6, min_power_for_fixed_pt=- 3)[source]

Calculates the pct chance and one-in chance of any list of numbers, including numbers not in the Events.

Parameters
  • query_list – A list of ints. Calculates the chance of the list getting rolled.

  • shown_digits – How many digits in each scientific notation number str.

  • max_power_for_commaed – The largest power to be represented in comma notation. if set to -1, all numbers >= 1 are in scientific notation.

  • min_power_for_fixed_pt – The smallest power to be represented in fixed point notation. If set to zero, all values < 1 represented in scientific notation.

Returns

(query values, query occurrences, total occurrences, inverse chance, pct chance)

>>> import dicetables as dt
>>> table = dt.DiceTable.new().add_die(dt.Die(6), 1000)
>>> calc = dt.EventsCalculations(table)
>>> calc.stddev(7)
54.0061725
>>> calc.mean()
3500.0
>>> the_stats = calc.stats_strings([3500], shown_digits=6) # Shown_digits defaults to 4.
>>> the_stats
StatsStrings(query_values='3,500',
             query_occurrences='1.04628e+776',
             total_occurrences='1.41661e+778',
             one_in_chance='135.395',
             pct_chance='0.738580')

This is correct. Out of 5000 possible rolls, 3500 has a 0.7% chance of occurring.

>>> the_stats.one_in_chance
'135.395'
>>> calc.stats_strings(list(range(1000, 3001)) + list(range(4000, 10000)))
StatsStrings(query_values='1,000-3,000, 4,000-9,999',
             query_occurrences='2.183e+758',
             total_occurrences='1.417e+778',
             one_in_chance='6.490e+19',
             pct_chance='1.541e-18')

This is also correct. Rolls not in the middle 1000 collectively have a much smaller chance than the mean.

>>> silly_table = dt.AdditiveEvents({1: 123456, 100: 1234567*10**1000})
>>> silly_calc = dt.EventsCalculations(silly_table, include_zeroes=False)
>>> print(silly_calc.full_table_string(shown_digits=6))
  1: 123,456
100: 1.23457e+1006

EventsCalculations.include_zeroes is only settable at instantiation. It does exactly what it says. EventCalculations owns an EventsInformation. So instantiating EventsCalculations gets you two for the price of one. It’s accessed with the property EventsCalculations.info .

>>> table = dt.DiceTable.new().add_die(dt.StrongDie(dt.Die(3), 2))
>>> calc = dt.EventsCalculations(table, True)
>>> print(calc.full_table_string())
2: 1
3: 0
4: 1
5: 0
6: 1

>>> calc = dt.EventsCalculations(table, False)
>>> print(calc.full_table_string())
2: 1
4: 1
6: 1

>>> calc.info.events_range()
(2, 6)

You can also access some functionality as wrapper functions.

dicetables.eventsinfo.events_range(events)[source]
dicetables.eventsinfo.mean(events)[source]
dicetables.eventsinfo.stddev(events, decimal_place=4)[source]
dicetables.eventsinfo.percentage_points(events, include_zeroes=True)[source]
dicetables.eventsinfo.percentage_axes(events, include_zeroes=True)[source]
dicetables.eventsinfo.stats(events, query_values, shown_digits=4)[source]
dicetables.eventsinfo.full_table_string(events, include_zeroes=True, shown_digits=4)[source]