Skip to content

Commit

Permalink
redo
Browse files Browse the repository at this point in the history
  • Loading branch information
alanlujan91 committed Nov 23, 2023
1 parent 6c7f91e commit 37c25a7
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions HARK/rewards.py
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,40 @@ def inv(self, *args, **kwargs):
return self.inverse(*args, **kwargs)


def CDutility(c, d, c_share, d_bar):
return c**c_share * (d + d_bar) ** (1 - c_share)

Check warning on line 727 in HARK/rewards.py

View check run for this annotation

Codecov / codecov/patch

HARK/rewards.py#L727

Added line #L727 was not covered by tests


def CDutilityPc(c, d, c_share, d_bar):
return c_share * ((d + d_bar) / c) ** (1 - c_share)

Check warning on line 731 in HARK/rewards.py

View check run for this annotation

Codecov / codecov/patch

HARK/rewards.py#L731

Added line #L731 was not covered by tests


def CDutilityPd(c, d, c_share, d_bar):
return (1 - c_share) * (c / (d + d_bar)) ** c_share

Check warning on line 735 in HARK/rewards.py

View check run for this annotation

Codecov / codecov/patch

HARK/rewards.py#L735

Added line #L735 was not covered by tests


def CDutilityPc_inv(uc, d, c_share, d_bar):
return (d + d_bar) * (uc / c_share) ** (1 / (1 - c_share))

Check warning on line 739 in HARK/rewards.py

View check run for this annotation

Codecov / codecov/patch

HARK/rewards.py#L739

Added line #L739 was not covered by tests


def CRRACDutility(c, d, c_share, d_bar, CRRA):
return CDutility(c, d, c_share, d_bar) ** (1 - CRRA) / (1 - CRRA)

Check warning on line 743 in HARK/rewards.py

View check run for this annotation

Codecov / codecov/patch

HARK/rewards.py#L743

Added line #L743 was not covered by tests


def CRRACDutilityPc(c, d, c_share, d_bar, CRRA):
return c_share / c * CDutility(c, d, c_share, d_bar) ** (1 - CRRA)

Check warning on line 747 in HARK/rewards.py

View check run for this annotation

Codecov / codecov/patch

HARK/rewards.py#L747

Added line #L747 was not covered by tests


def CRRACDutilityPd(c, d, c_share, d_bar, CRRA):
return (1 - c_share) / (d + d_bar) * CDutility(c, d, c_share, d_bar) ** (1 - CRRA)

Check warning on line 751 in HARK/rewards.py

View check run for this annotation

Codecov / codecov/patch

HARK/rewards.py#L751

Added line #L751 was not covered by tests


def CRRACDutilityPc_inv(uc, d, c_share, d_bar, CRRA):
return (c_share / uc * (d + d_bar) ** (c_share * CRRA - c_share - CRRA + 1)) ** (

Check warning on line 755 in HARK/rewards.py

View check run for this annotation

Codecov / codecov/patch

HARK/rewards.py#L755

Added line #L755 was not covered by tests
1 / (c_share * CRRA - c_share + 1)
)


class UtilityFuncCRRA(UtilityFunction):
"""
A class for representing a CRRA utility function.
Expand Down Expand Up @@ -889,9 +923,7 @@ def __init__(self, EOS, factor=1.0):
self.EOS = np.asarray(EOS)
self.factor = factor

assert np.isclose(
np.sum(self.EOS), 1.0
), """The sum of the elasticity of substitution
assert np.isclose(np.sum(self.EOS), 1.0), """The sum of the elasticity of substitution

Check warning on line 926 in HARK/rewards.py

View check run for this annotation

Codecov / codecov/patch

HARK/rewards.py#L926

Added line #L926 was not covered by tests
parameters must be less than or equal to 1."""

assert factor > 0, "Factor must be positive."
Expand Down

0 comments on commit 37c25a7

Please sign in to comment.