text stringlengths 81 112k |
|---|
Set the join clause for the query.
def _set_join(self, query=None):
"""
Set the join clause for the query.
"""
if not query:
query = self._query
foreign_key = '%s.%s' % (self._related.get_table(), self._second_key)
query.join(self._parent.get_table(), self.... |
Violinplots of the highest and lowest scoring of each modality
def plot_best_worst_fits(assignments_df, data, modality_col='Modality',
score='$\log_2 K$'):
"""Violinplots of the highest and lowest scoring of each modality"""
ncols = 2
nrows = len(assignments_df.groupby(modality_col... |
Wrapper around Seaborn's Violinplot specifically for [0, 1] ranged data
What's different:
- bw = 0.2: Sets bandwidth to be small and the same between datasets
- scale = 'width': Sets the width of all violinplots to be the same
- inner = None: Don't plot a boxplot or points inside the violinplot
def vi... |
Draw barplots grouped by modality of modality percentage per group
Parameters
----------
Returns
-------
Raises
------
def bar(self, counts, phenotype_to_color=None, ax=None, percentages=True):
"""Draw barplots grouped by modality of modality percentage per ... |
Show the values underlying bayesian modality estimations of an event
Parameters
----------
Returns
-------
Raises
------
def event_estimation(self, event, logliks, logsumexps, renamed=''):
"""Show the values underlying bayesian modality estimations of an eve... |
Assign the most likely modality given the fitted data
Parameters
----------
fitted : pandas.DataFrame or pandas.Series
Either a (n_modalities, features) DatFrame or (n_modalities,)
Series, either of which will return the best modality for each
feature.
def p... |
Calculate log-likelihood of a feature x for each model
Converts all values that are exactly 1 or exactly 0 to 0.999 and 0.001
because they are out of range of the beta distribution.
Parameters
----------
x : numpy.array-like
A single vector to estimate the log-likel... |
Convert floats to either integers or a nice looking fraction
def nice_number_string(number, decimal_places=2):
"""Convert floats to either integers or a nice looking fraction"""
if number == np.round(number):
return str(int(number))
elif number < 1 and number > 0:
invers... |
Plot violins of each distribution in the model family
Parameters
----------
n : int
Number of random variables to generate
kwargs : dict or keywords
Any keyword arguments to seaborn.violinplot
Returns
-------
ax : matplotlib.Axes object
... |
Get log-likelihood of models at each parameterization for given data
Parameters
----------
feature : pandas.Series
Percent-based values of a single feature. May contain NAs, but only
non-NA values are used.
Returns
-------
logliks : pandas.DataFr... |
Get the modality assignments of each splicing event in the data
Parameters
----------
data : pandas.DataFrame
A (n_samples, n_events) dataframe of splicing events' PSI scores.
Must be psi scores which range from 0 to 1
Returns
-------
log2_bayes_... |
Guess the most likely modality for each event
For each event that has at least one non-NA value, if no modalilites
have logsumexp'd logliks greater than the log Bayes factor threshold,
then they are assigned the 'multimodal' modality, because we cannot
reject the null hypothesis that th... |
Calculate log-likelihoods of each modality's parameterization
Used for plotting the estimates of a single feature
Parameters
----------
featre : pandas.Series
A single feature's values. All values must range from 0 to 1.
Returns
-------
logliks : pa... |
Get the log2 bayes factor of the fit for each modality
def single_feature_fit(self, feature):
"""Get the log2 bayes factor of the fit for each modality"""
if np.isfinite(feature).sum() == 0:
series = pd.Series(index=MODALITY_ORDER)
else:
logbf_one_param = pd.Series(
... |
r"""Visualize all modality family members with parameters
Use violinplots to visualize distributions of modality family members
Parameters
----------
n : int
Number of random variables to generate
kwargs : dict or keywords
Any keyword arguments to seabor... |
Given a list of bins, make a list of strings of those bin ranges
Parameters
----------
bins : list_like
List of anything, usually values of bin edges
Returns
-------
bin_ranges : list
List of bin ranges
>>> bin_range_strings((0, 0.5, 1))
['0-0.5', '0.5-1']
def bin_ran... |
Makes a histogram of each column the provided binsize
Parameters
----------
data : pandas.DataFrame
A samples x features dataframe. Each feature (column) will be binned
into the provided bins
bins : iterable
Bins you would like to use for this data. Must include the final bin
... |
Kullback-Leiber divergence of two probability distributions pandas
dataframes, p and q
Parameters
----------
p : pandas.DataFrame
An nbins x features DataFrame, or (nbins,) Series
q : pandas.DataFrame
An nbins x features DataFrame, or (nbins,) Series
Returns
-------
kld... |
Finds the per-column JSD between dataframes p and q
Jensen-Shannon divergence of two probability distrubutions pandas
dataframes, p and q. These distributions are usually created by running
binify() on the dataframe.
Parameters
----------
p : pandas.DataFrame
An nbins x features DataFr... |
Find the entropy of each column of a dataframe
Parameters
----------
binned : pandas.DataFrame
A nbins x features DataFrame of probability distributions, where each
column sums to 1
base : numeric
The log-base of the entropy. Default is 2, so the resulting entropy
is in ... |
Binify and calculate jensen-shannon divergence between two dataframes
Parameters
----------
df1, df2 : pandas.DataFrames
Dataframes to calculate JSD between columns of. Must have overlapping
column names
bins : array-like
Bins to use for transforming df{1,2} into probability dis... |
Jensen-Shannon divergence of features across phenotypes
Parameters
----------
data : pandas.DataFrame
A (n_samples, n_features) Dataframe
groupby : mappable
A samples to phenotypes mapping
n_iter : int
Number of bootstrap resampling iterations to perform for the
with... |
Transform a tall JSD dataframe to a square matrix of mean JSDs
Parameters
----------
jsd_df : pandas.DataFrame
A (n_features, n_phenotypes^2) dataframe of the JSD between each
feature between and within phenotypes
Returns
-------
jsd_2d : pandas.DataFrame
A (n_phenotype... |
Start pcap's loop over the interface, calling the given callback for each packet
:param callback: a function receiving (win_pcap, param, header, pkt_data) for each packet intercepted
:param limit: how many packets to capture (A value of -1 or 0 is equivalent to infinity)
def run(self, callback=None, li... |
send a buffer as a packet to the network interface
:param packet_buffer: buffer to send (length shouldn't exceed MAX_INT)
def send(self, packet_buffer):
"""
send a buffer as a packet to the network interface
:param packet_buffer: buffer to send (length shouldn't exceed MAX_INT)
... |
:param pattern: a wildcard pattern to match the description of a network interface to capture packets on
:param callback: a function to call with each intercepted packet
def capture_on(pattern, callback):
"""
:param pattern: a wildcard pattern to match the description of a network interface to ... |
:param device_name: the name (guid) of a device as provided by WinPcapDevices.list_devices()
:param callback: a function to call with each intercepted packet
def capture_on_device_name(device_name, callback):
"""
:param device_name: the name (guid) of a device as provided by WinPcapDevices.list... |
Send a buffer as a packet to a network interface and optionally capture a response
:param pattern: a wildcard pattern to match the description of a network interface to capture packets on
:param packet_buffer: a buffer to send (length shouldn't exceed MAX_INT)
:param callback: If not None, a fun... |
Return the next value for a given sequence.
def get_next_value(
sequence_name='default', initial_value=1, reset_value=None,
*, nowait=False, using=None):
"""
Return the next value for a given sequence.
"""
# Inner import because models cannot be imported before their application.
f... |
Check the status of all provided data and update the suite.
def check(self, final_line_count):
"""Check the status of all provided data and update the suite."""
if self._lines_seen["version"]:
self._process_version_lines()
self._process_plan_lines(final_line_count) |
Process version line rules.
def _process_version_lines(self):
"""Process version line rules."""
if len(self._lines_seen["version"]) > 1:
self._add_error(_("Multiple version lines appeared."))
elif self._lines_seen["version"][0] != 1:
self._add_error(_("The version must b... |
Process plan line rules.
def _process_plan_lines(self, final_line_count):
"""Process plan line rules."""
if not self._lines_seen["plan"]:
self._add_error(_("Missing a plan."))
return
if len(self._lines_seen["plan"]) > 1:
self._add_error(_("Only one plan line... |
Check if a plan is on a valid line.
def _plan_on_valid_line(self, at_line, final_line_count):
"""Check if a plan is on a valid line."""
# Put the common cases first.
if at_line == 1 or at_line == final_line_count:
return True
# The plan may only appear on line 2 if the vers... |
Handle a bail line.
def handle_bail(self, bail):
"""Handle a bail line."""
self._add_error(_("Bailed: {reason}").format(reason=bail.reason)) |
Handle a plan that contains a SKIP directive.
def handle_skipping_plan(self, skip_plan):
"""Handle a plan that contains a SKIP directive."""
skip_line = Result(True, None, skip_plan.directive.text, Directive("SKIP"))
self._suite.addTest(Adapter(self._filename, skip_line)) |
Add an error test to the suite.
def _add_error(self, message):
"""Add an error test to the suite."""
error_line = Result(False, None, message, Directive(""))
self._suite.addTest(Adapter(self._filename, error_line)) |
Format an exception as diagnostics output.
exception is the tuple as expected from sys.exc_info.
def format_exception(exception):
"""Format an exception as diagnostics output.
exception is the tuple as expected from sys.exc_info.
"""
exception_lines = traceback.format_exception(*exception)
# ... |
Generate tap.line.Line objects, given a file-like object `fh`.
`fh` may be any object that implements both the iterator and
context management protocol (i.e. it can be used in both a
"with" statement and a "for...in" statement.)
Trailing whitespace and newline characters will be automa... |
Parse a line into whatever TAP category it belongs.
def parse_line(self, text, fh=None):
"""Parse a line into whatever TAP category it belongs."""
match = self.ok.match(text)
if match:
return self._parse_result(True, match, fh)
match = self.not_ok.match(text)
if mat... |
Parse a matching plan line.
def _parse_plan(self, match):
"""Parse a matching plan line."""
expected_tests = int(match.group("expected"))
directive = Directive(match.group("directive"))
# Only SKIP directives are allowed in the plan.
if directive.text and not directive.skip:
... |
Parse a matching result line into a result instance.
def _parse_result(self, ok, match, fh=None):
"""Parse a matching result line into a result instance."""
peek_match = None
try:
if fh is not None and self._try_peeking:
peek_match = self.yaml_block_start.match(fh.pe... |
Extract a raw yaml block from a file handler
def _extract_yaml_block(self, indent, fh):
"""Extract a raw yaml block from a file handler"""
raw_yaml = []
indent_match = re.compile(r"^{}".format(indent))
try:
fh.next()
while indent_match.match(fh.peek()):
... |
Lazy load a yaml_block.
If yaml support is not available,
there is an error in parsing the yaml block,
or no yaml is associated with this result,
``None`` will be returned.
:rtype: dict
def yaml_block(self):
"""Lazy load a yaml_block.
If yaml support is not av... |
Load any files found into a suite.
Any directories are walked and their files are added as TAP files.
:returns: A ``unittest.TestSuite`` instance
def load(self, files):
"""Load any files found into a suite.
Any directories are walked and their files are added as TAP files.
:... |
Load a test suite with test lines from the provided TAP file.
:returns: A ``unittest.TestSuite`` instance
def load_suite_from_file(self, filename):
"""Load a test suite with test lines from the provided TAP file.
:returns: A ``unittest.TestSuite`` instance
"""
suite = unittest... |
Load a test suite with test lines from the TAP stream on STDIN.
:returns: A ``unittest.TestSuite`` instance
def load_suite_from_stdin(self):
"""Load a test suite with test lines from the TAP stream on STDIN.
:returns: A ``unittest.TestSuite`` instance
"""
suite = unittest.Test... |
Load a suite with lines produced by the line generator.
def _load_lines(self, filename, line_generator, suite, rules):
"""Load a suite with lines produced by the line generator."""
line_counter = 0
for line in line_generator:
line_counter += 1
if line.category in self.i... |
Keep track of which test cases have executed.
def _track(self, class_name):
"""Keep track of which test cases have executed."""
if self._test_cases.get(class_name) is None:
if self.streaming and self.header:
self._write_test_case_header(class_name, self.stream)
... |
Notify the tracker how many total tests there will be.
def set_plan(self, total):
"""Notify the tracker how many total tests there will be."""
self.plan = total
if self.streaming:
# This will only write the plan if we haven't written it
# already but we want to check if ... |
Generate TAP reports.
The results are either combined into a single output file or
the output file name is generated from the test case.
def generate_tap_reports(self):
"""Generate TAP reports.
The results are either combined into a single output file or
the output file name i... |
Write the plan line to the stream.
If we have a plan and have not yet written it out, write it to
the given stream.
def _write_plan(self, stream):
"""Write the plan line to the stream.
If we have a plan and have not yet written it out, write it to
the given stream.
"""... |
Get the TAP output file path for the test case.
def _get_tap_file_path(self, test_case):
"""Get the TAP output file path for the test case."""
sanitized_test_case = test_case.translate(self._sanitized_table)
tap_file = sanitized_test_case + ".tap"
if self.outdir:
return os.p... |
Entry point for ``tappy`` command.
def main(argv=sys.argv, stream=sys.stderr):
"""Entry point for ``tappy`` command."""
args = parse_args(argv)
suite = build_suite(args)
runner = unittest.TextTestRunner(verbosity=args.verbose, stream=stream)
result = runner.run(suite)
return get_status(result) |
Build a test suite by loading TAP files or a TAP stream.
def build_suite(args):
"""Build a test suite by loading TAP files or a TAP stream."""
loader = Loader()
if len(args.files) == 0 or args.files[0] == "-":
suite = loader.load_suite_from_stdin()
else:
suite = loader.load(args.files)
... |
Add a failure to the result.
def addFailure(self, result):
"""Add a failure to the result."""
result.addFailure(self, (Exception, Exception(), None))
# Since TAP will not provide assertion data, clean up the assertion
# section so it is not so spaced out.
test, err = result.fail... |
Based on example
https://bitbucket.org/zzzeek/sqlalchemy/src/73095b353124/examples/nested_sets/nested_sets.py?at=master
def mptt_before_insert(mapper, connection, instance):
""" Based on example
https://bitbucket.org/zzzeek/sqlalchemy/src/73095b353124/examples/nested_sets/nested_sets.py?at=master
"""
... |
Based on this example:
http://stackoverflow.com/questions/889527/move-node-in-nested-set
def mptt_before_update(mapper, connection, instance):
""" Based on this example:
http://stackoverflow.com/questions/889527/move-node-in-nested-set
"""
node_id = getattr(instance, instance.get_pk_name())... |
Event listener to recursively expire `left` and `right` attributes the
parents of all modified instances part of this flush.
def after_flush_postexec(self, session, context):
"""
Event listener to recursively expire `left` and `right` attributes the
parents of all modified instances par... |
class or instance level method which returns True if self is
ancestor (closer to root) of other else False. Optional flag
`inclusive` on whether or not to treat self as ancestor of self.
For example see:
* :mod:`sqlalchemy_mptt.tests.cases.integrity.test_hierarchy_structure`
def is_an... |
Moving one node of tree inside another
For example see:
* :mod:`sqlalchemy_mptt.tests.cases.move_node.test_move_inside_function`
* :mod:`sqlalchemy_mptt.tests.cases.move_node.test_move_inside_to_the_same_parent_function`
def move_inside(self, parent_id):
""" Moving one node of tree in... |
Moving one node of tree after another
For example see :mod:`sqlalchemy_mptt.tests.cases.move_node.test_move_after_function`
def move_after(self, node_id):
""" Moving one node of tree after another
For example see :mod:`sqlalchemy_mptt.tests.cases.move_node.test_move_after_function`
""... |
Moving one node of tree before another
For example see:
* :mod:`sqlalchemy_mptt.tests.cases.move_node.test_move_before_function`
* :mod:`sqlalchemy_mptt.tests.cases.move_node.test_move_before_to_other_tree`
* :mod:`sqlalchemy_mptt.tests.cases.move_node.test_move_before_to_top_level`
d... |
Node to the left of the current node at the same level
For example see
:mod:`sqlalchemy_mptt.tests.cases.get_tree.test_leftsibling_in_level`
def leftsibling_in_level(self):
""" Node to the left of the current node at the same level
For example see
:mod:`sqlalchemy_mptt.tests.c... |
Helper method for ``get_tree``.
def _node_to_dict(cls, node, json, json_fields):
""" Helper method for ``get_tree``.
"""
if json:
pk_name = node.get_pk_name()
# jqTree or jsTree format
result = {'id': getattr(node, pk_name), 'label': node.__repr__()}
... |
This method generate tree of current node table in dict or json
format. You can make custom query with attribute ``query``. By default
it return all nodes in table.
Args:
session (:mod:`sqlalchemy.orm.session.Session`): SQLAlchemy session
Kwargs:
json (bool): if... |
This method generate a branch from a tree, begining with current
node.
For example:
node7.drilldown_tree()
.. code::
level Nested sets example
1 1(1)22 ---------------------
___________... |
Generate path from a leaf or intermediate node to the root.
For example:
node11.path_to_root()
.. code::
level Nested sets example
-----------------------------------------
1 | 1(1)22 ... |
This method rebuid tree.
Args:
session (:mod:`sqlalchemy.orm.session.Session`): SQLAlchemy session
tree_id (int or str): id of tree
Example:
* :mod:`sqlalchemy_mptt.tests.cases.get_tree.test_rebuild`
def rebuild_tree(cls, session, tree_id):
""" This method reb... |
This function rebuid tree.
Args:
session (:mod:`sqlalchemy.orm.session.Session`): SQLAlchemy session
Kwargs:
tree_id (int or str): id of tree, default None
Example:
* :mod:`sqlalchemy_mptt.tests.TestTree.test_rebuild`
def rebuild(cls, session, tree_id=None):
... |
qx: Returns the probability that a life aged x dies before 1 year
With the convention: the true probability is qx/1000
Args:
mt: the mortality table
x: the age as integer number.
def qx(mt, x):
""" qx: Returns the probability that a life aged x dies before 1 year
With th... |
lx : Returns the number of survivors at begining of age x
def lx(mt, x):
""" lx : Returns the number of survivors at begining of age x """
if x < len(mt.lx):
return mt.lx[x]
else:
return 0 |
Returns the number of dying at begining of age x
def dx(mt, x):
""" Returns the number of dying at begining of age x """
end_x_val = mt.lx.index(0)
if x < end_x_val:
return mt.lx[x] - mt.lx[x + 1]
else:
return 0.0 |
tpx : Returns the probability that x will survive within t years
def tpx(mt, x, t):
""" tpx : Returns the probability that x will survive within t years """
""" npx : Returns n years survival probability at age x """
return mt.lx[x + t] / mt.lx[x] |
nqx : Returns the probability to die within n years at age x
def tqx(mt, x, t):
""" nqx : Returns the probability to die within n years at age x """
return (mt.lx[x] - mt.lx[x + t]) / mt.lx[x] |
n/qx : Probability to die in n years being alive at age x.
Probability that x survives n year, and then dies in th subsequent t years
def tqxn(mt, x, n, t):
""" n/qx : Probability to die in n years being alive at age x.
Probability that x survives n year, and then dies in th subsequent t years """
retu... |
ex : Returns the curtate expectation of life. Life expectancy
def ex(mt, x):
""" ex : Returns the curtate expectation of life. Life expectancy """
sum1 = 0
for j in mt.lx[x + 1:-1]:
sum1 += j
#print sum1
try:
return sum1 / mt.lx[x] + 0.5
except:
return 0 |
Return the Sx
def Sx(mt, x):
""" Return the Sx """
n = len(mt.Nx)
sum1 = 0
for j in range(x, n):
k = mt.Nx[j]
sum1 += k
return sum1 |
Return the Cx
def Cx(mt, x):
""" Return the Cx """
return ((1 / (1 + mt.i)) ** (x + 1)) * mt.dx[x] * ((1 + mt.i) ** 0.5) |
Return the Mx
def Mx(mt, x):
""" Return the Mx """
n = len(mt.Cx)
sum1 = 0
for j in range(x, n):
k = mt.Cx[j]
sum1 += k
return sum1 |
nEx : Returns the EPV of a pure endowment (deferred capital).
Pure endowment benefits are conditional on the survival of the policyholder. (v^n * npx)
def nEx(mt, x, n):
""" nEx : Returns the EPV of a pure endowment (deferred capital).
Pure endowment benefits are conditional on the survival of the policy... |
(A^1)x:n : Returns the EPV (net single premium) of a term insurance.
def Axn(mt, x, n):
""" (A^1)x:n : Returns the EPV (net single premium) of a term insurance. """
return (mt.Mx[x] - mt.Mx[x + n]) / mt.Dx[x] |
AExn : Returns the EPV of a endowment insurance.
An endowment insurance provides a combination of a term insurance and a pure endowment
def AExn(mt, x, n):
""" AExn : Returns the EPV of a endowment insurance.
An endowment insurance provides a combination of a term insurance and a pure endowment
"""
... |
n/Ax : Returns the EPV (net single premium) of a deferred whole life insurance.
def tAx(mt, x, t):
""" n/Ax : Returns the EPV (net single premium) of a deferred whole life insurance. """
return mt.Mx[x + t] / mt.Dx[x] |
This function evaluates the APV of a geometrically increasing annual annuity-due
def qAx(mt, x, q):
""" This function evaluates the APV of a geometrically increasing annual annuity-due """
q = float(q)
j = (mt.i - q) / (1 + q)
mtj = Actuarial(nt=mt.nt, i=j)
return Ax(mtj, x) |
äxn : Return the actuarial present value of a (immediate) temporal (term certain) annuity:
n-year temporary life annuity-anticipatory. Payable 'm' per year at the beginning of the period
def aaxn(mt, x, n, m=1):
""" äxn : Return the actuarial present value of a (immediate) temporal (term certain) annuity:
... |
äx : Returns the actuarial present value of an (immediate) annuity of 1 per time period
(whole life annuity-anticipatory). Payable 'm' per year at the beginning of the period
def aax(mt, x, m=1):
""" äx : Returns the actuarial present value of an (immediate) annuity of 1 per time period
(whole life annui... |
ax : Returns the actuarial present value of an (immediate) annuity of 1 per time period
(whole life annuity-late). Payable 'm' per year at the ends of the period
def ax(mt, x, m=1):
""" ax : Returns the actuarial present value of an (immediate) annuity of 1 per time period
(whole life annuity-late). Paya... |
n/äx : Return the actuarial present value of a deferred annuity (deferred n years):
n-year deferred whole life annuity-anticipatory. Payable 'm' per year at the beginning of the period
def taax(mt, x, t, m=1):
""" n/äx : Return the actuarial present value of a deferred annuity (deferred n years):
n-year ... |
during a term certain, IAn
def Iaaxn(mt, x, n, *args):
""" during a term certain, IAn """
return (Sx(mt, x) - Sx(nt, x + n) - n * Nx(nt, x + n)) / Dx(nt, x) |
during a term certain, IAn
def Iaxn(mt, x, n, *args):
""" during a term certain, IAn """
return (Sx(mt, x + 1) - Sx(mt, x + n + 1) - n * Nx(mt, x + n + 1)) / Dx(mt, x) |
(Iä)x : Returns the present value of annuity-certain at the beginning of the first year
and increasing linerly. Arithmetically increasing annuity-anticipatory
def Iaax(mt, x, *args):
""" (Iä)x : Returns the present value of annuity-certain at the beginning of the first year
and increasing linerly. Arithm... |
(Ia)x : Returns the present value of annuity-certain at the end of the first year
and increasing linerly. Arithmetically increasing annuity-late
def Iax(mt, x, *args):
""" (Ia)x : Returns the present value of annuity-certain at the end of the first year
and increasing linerly. Arithmetically increasing a... |
deffered t years
def Itaax(mt, x, t):
""" deffered t years """
return (Sx(mt, x) - Sx(mt, x + t)) / Dx(mt, x) |
deffered t years
def Itax(mt, x, t):
""" deffered t years """
return (Sx(mt, x + 1) - Sx(mt, x + t + 1)) / Dx(mt, x) |
geometrica
def qax(mt, x, q, m=1):
""" geometrica """
q = float(q)
j = (mt.i - q) / (1 + q)
mtj = Actuarial(nt=mt.nt, i=j)
return ax(mtj, x, m) |
geometrica
def qaax(mt, x, q, m=1):
""" geometrica """
q = float(q)
j = (mt.i - q) / (1 + q)
mtj = Actuarial(nt=mt.nt, i=j)
return aax(mtj, x, m) |
geometrica
def qaxn(mt, x, n, q, m=1):
""" geometrica """
q = float(q)
j = (mt.i - q) / (1 + q)
mtj = Actuarial(nt=mt.nt, i=j)
return axn(mtj, x, n, m) |
geometrica
def qaaxn(mt, x, n, q, m = 1):
""" geometrica """
#i = float(nt[1])
q = float(q)
j = (mt.i - q) / (1 + q)
mtj = Actuarial(nt=mt.nt, i=j)
return aaxn(mtj, x, n, m) |
geometrica
def qtax(mt, x, t, q, m=1):
""" geometrica """
q = float(q)
j = (mt.i - q) / (1 + q)
mtj = Actuarial(nt=mt.nt, i=j)
return tax(mtj, x, t) + ((float(m - 1) / float(m * 2)) * (1 - nEx(mt, x, t))) |
geometrica
def qtaax(mt, x, t, q, m=1):
""" geometrica """
q = float(q)
j = (mt.i - q) / (1 + q)
mtj = Actuarial(nt=mt.nt, i=j)
return taax(mtj, x, t) - ((float(m - 1) / float(m * 2)) * (1 - nEx(mt, x, t))) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.