Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial ages #572

Merged
merged 14 commits into from
Jul 1, 2024
Merged

Initial ages #572

merged 14 commits into from
Jul 1, 2024

Conversation

RomeshA
Copy link
Contributor

@RomeshA RomeshA commented Jun 28, 2024

Description

This PR uses rv_histogram to sample ages based on binned age data inputs. This resolves the current issue that initial ages are only integer values (or more specifically, the initial ages are only sampled from the lower bin edges).

Main:

main

This PR:

new

Larger bin widths now also work more correctly - with 10 year age bins e.g.

age,value
0,220.548
10,145.86
20,102.081
30,57.429
40,40.608
50,30.367
60,18.467
70,10.929
80,3.812
90,0.398
100,0.008
110,0

Main:
main10

This PR:
new10

Checklist

  • Code commented & docstrings added
  • New tests were needed and have been added
  • A new version number was needed & changelog has been updated
  • A new PyPI version needs to be released

@RomeshA RomeshA requested a review from cliffckerr June 30, 2024 22:35
Copy link
Contributor

@cliffckerr cliffckerr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@cliffckerr
Copy link
Contributor

Ah actually @RomeshA , I thought the docs build was failing idiopathically, but it's an actual error:

--> 107             dist = ss.Dist(rv_histogram((age_props,np.append(age_bins, age_bins[-1]+1)), density=age_props.sum() == 1), name='Age distribution')
    108         return dist

/software/anaconda3/lib/python3.11/site-packages/scipy/stats/_continuous_distns.py in ?(self, histogram, density, *args, **kwargs)
  10952                        "Specify `density` explicitly to silence this warning.")
  10953             warnings.warn(message, RuntimeWarning, stacklevel=2)
  10954             density = True
  10955         elif not density:
> 10956             self._hpdf = self._hpdf / self._hbin_widths
  10957 
  10958         self._hpdf = self._hpdf / float(np.sum(self._hpdf * self._hbin_widths))
  10959         self._hcdf = np.cumsum(self._hpdf * self._hbin_widths)

ValueError: operands could not be broadcast together with shapes (101,2) (101,) 

We should fix this before merging

@cliffckerr cliffckerr merged commit 0279c34 into main Jul 1, 2024
3 checks passed
@cliffckerr cliffckerr deleted the initial_ages branch July 1, 2024 22:50
@robynstuart robynstuart restored the initial_ages branch July 10, 2024 23:05
@cliffckerr cliffckerr deleted the initial_ages branch September 11, 2024 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants