Skip to content

More flexible sob_terms #65

@mjlarson

Description

@mjlarson

At L126 of test_statistics.py, we have a construction like this:

for term in self._sob_terms:
      sob *= term(params, self._events)

Because the terms are treated independently and sequentially, this provides an incredible opportunity for us to provide flexibility in the test statistics. Imagine a rewrite that lets us do this:

events = self._events.copy()
for term in self._sob_terms:
      events, sob = term(params, events, sob)

This would allow us to do filtering of events during each term based on the current total sob. We could then have something like a TXS analysis that does this:

def txs_like_uniform(params, events, sob):
    # find the pair that gives the largest increase in sob, which
    # should correspond roughly to the most interesting window
    cumulative_sob = np.cumsum(np.log(sob))  # assumes time-sorted
    
    # potentially memory-intensive! Probably a better way to do this,
    # but haven't sunk much thought into it yet.
    increase = cumulative_sob[np.newaxis, :] - cumulative_sob[:, np.newaxis]
    indices = np.argwhere(increase == increase.max())
    
    result = np.zeros_like(sob)
    result[indices[0]:indicies[1]] = (sig_time_profile(events[indices[0]:indices[1]]) 
                                                         / bg_time_profile(events[indices[0]:indices[1]]))
    return events, sob*result

This wouldn't let you make the fancy TS/p vs time plots, but it could prevent you from needing to minimize independently for each pair. You could also incorporate the Erlang time stuff this way without any other changes to the code, since it would be able to filter events inside of the time likelihood term itself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions