# Ticket #969 (new wish)

## Consider making Contingency more efficient

Reported by: | janez | Owned by: | janez |
---|---|---|---|

Milestone: | 3.0 | Component: | other |

Severity: | minor | Keywords: | |

Cc: | Blocking: | ||

Blocked By: |

### Description

In particular, in discrete-vs-discrete case it can be stored as double *, and in continuous-vs-discrete as map<double, TDiscDistribution> (instead of map<double, PDistribution>).

In either case, we will have problems with operator[] that returns a PDistribution. A possible solution is to allow TDiscDistribution::distribution to point to shared data. In that case, TDiscDistribution::distribution_ would be put in union with a bool telling whether the data is owned or borrowed.

The question is how much would we gain by this optimization, in particular in discrete-vs-discrete case. Discrete contingency tables are typically small.

**Note:**See TracTickets for help on using tickets.