Python_modules.mmcomplexity Module¶
Python module to analyze mental model complexity in our Auditory change-point task
To generate a block of trials with fixed hazard rate on the sources, use the StimulusBlock class.
To build your own decision-making model, base your class on BinaryDecisionMaker.
- Pre-existing sequential-update decision-making models are provided in this module:
KnownHazard: UnknownHazard
- To initialize the models, you must provide a stimulus block and call the observe method.
>>> stim = StimulusBlock(100, .2) # stimulus block with hazard rate 0.2 and 100 trials >>> dm = KnownHazard(stim) >>> dm.observe()
- To run the decision making algorithm on a sequence of trials, we use generators:
>>> gen1 = dm.process(target='source', filter_step=1) # predict the next source >>> dec1 = list(gen1) # list of tuples (log-posterior odds, decision) >>> gen2 = dm.process(target='source', filter_step=0) # infer the current source >>> dec2 = list(gen2) # list of tuples (log-posterior odds, decision) >>> gen3 = dm.process(hazard=.9, filter_step=1) # prediction model where we force believed hazard rate to be 0.9 >>> dec3 = list(gen3)
To produce a sequence of trials with hazards that vary according to their own meta-hazard rate, use the class Audio2AFCSimulation. Below, we generate 400 trials with hazards being either 0.1 or 0.9, a meta hazard rate of 0.01 and flat prior on the hazard values.
>>> sim = Audio2AFCSimulation(400, [0.1, 0.9], .01, [0.5,0.5])
>>> sim.data.head() # trial info is contained in a pandas.DataFrame
– Technical note – to activate warnings in interactive Shell, type:
>>> import warnings
>>> import mmcomplexity as mmx
>>> warnings.filterwarnings("default", category=DeprecationWarning, module=mmx.get("__name__"))
Functions¶
|
checks that sum of elements in array is 1, up to TOLERANCE level |
Check that all elements in sides are valid sides |
|
|
Check that side is in the allowed set of sides |
|
iterate through seq and flag change points with False boolean. |
Sample from geometric distribution to tell us when the next change point will occur |
|
|
Given |
|
returns posterior over sources, given the log-posterior odds |
|
Args: |
|
Args: |
|
Args: |
|
Args: |
Classes¶
|
Use this class to launch simulations of our models |
|
Base class to simulate an observer performing our Auditory change-point 2AFC task. |
|
Binary decision maker which is an ideal observer who knows the true hazard rate value and assumes it fixed. |
|
Define stimulus for a block of trials in which hazard rate is fixed |
|
Variables¶
int([x]) -> integer int(x, base=10) -> integer |
|
set of allowed sides |
|
under this threshold, a probability is deemed to be 0 |
|
A Bernoulli discrete random variable. |
|
A beta continuous random variable. |
Class Inheritance Diagram¶

Python_modules.tests_mmcomplexity Module¶
This is a test module to test the mmcomplexity module with unittest Main reference: https://docs.python.org/3/library/unittest.html#unittest.TestCase.setUp
Classes¶
|
|
|
|
|
|
|
|
|
Class Inheritance Diagram¶
