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

updating the fixed time separation #289

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Conversation

HenningSE
Copy link
Collaborator

What does the code in this PR do / what does it improve?

The PR fixes a problem with the time calculation in the fixed spacing option. Up to now we use np.arange with a fixed step size to produce the event times. This caused a shape mismatch as num_interactions+1 times are generated. With this PR, np.linspace will be used to generate a matching number of times.

@HenningSE HenningSE marked this pull request as ready for review February 6, 2025 12:10
@coveralls
Copy link

coveralls commented Feb 6, 2025

Pull Request Test Coverage Report for Build 13387833972

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 79.962%

Totals Coverage Status
Change from base Build 13387532307: 0.0%
Covered Lines: 2534
Relevant Lines: 3169

💛 - Coveralls

@cfuselli
Copy link
Member

cfuselli commented Feb 6, 2025

Hey @HenningSE ,
I gave a quick try with both functions, and to me it seems like they both produce num_interactions points.
See here:

Testing functions:
num_interactions: 10
event_rate: 0.1
--------------------------------------------------
Using np.arange (current)
10 interaction times: [ 0. 10. 20. 30. 40. 50. 60. 70. 80. 90.]
Using np.linspace (proposed)
10 interaction times: [  0.          11.11111111  22.22222222  33.33333333  44.44444444
  55.55555556  66.66666667  77.77777778  88.88888889 100.        ]

Or am I missing something?

[ output produced with: ]

import numpy as np 
num_interactions = 10
event_rate = 0.1
a = np.arange(
    start=0, stop=num_interactions / event_rate, step=1 / event_rate
    )
b = np.linspace(
    start=0, stop=(num_interactions) / event_rate, num=num_interactions
)

print("Testing functions:")
print(f"num_interactions: {num_interactions}")
print(f"event_rate: {event_rate}")
print("-"*50)
print("Using np.arange (current)")
print(f"{len(a)} interaction times: {a}")
print("Using np.linspace (proposed)")
print(f"{len(b)} interaction times: {b}")

@HenningSE
Copy link
Collaborator Author

Hi @cfuselli you are right. I can not produce the error right now, maybe it was just a strange combination of numbers when it showed up. I will have a closer look next time I run some simulations.

@HenningSE HenningSE marked this pull request as draft February 18, 2025 09:54
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.

3 participants