Python Forum
Random data generation sum to 1 by rounding
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Random data generation sum to 1 by rounding
#3
Millions of thanks @bowlofred
I have a small question about your solution. When I run your code, I get sometimes a list like this:
Output:
[0.05, 0.0, 0.11, 0.26, 0.02, 0.07, 0.03, 0.1, 0.07, 0.29]
So there is a 0.0 in the second index.
How can I get rid of it and I always get strictly positive values as in your example?
Thank you so much
Reply


Messages In This Thread
RE: Random data generation sum to 1 by rounding - by juniorcoder - Oct-03-2021, 10:46 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  need help rounding joseph202020 7 1,411 Feb-21-2023, 08:13 PM
Last Post: joseph202020
  Node Flow Generation in Python Linenloid 0 677 Feb-21-2023, 07:09 PM
Last Post: Linenloid
  Allure Report Generation rotemz 0 825 Jan-24-2023, 08:30 PM
Last Post: rotemz
  from numpy array to csv - rounding SchroedingersLion 6 2,317 Nov-14-2022, 09:09 PM
Last Post: deanhystad
  Why doesnt chunk generation work? LotosProgramer 1 1,983 Apr-02-2022, 08:25 AM
Last Post: deanhystad
  Rounding issue kmll 1 1,461 Oct-08-2021, 10:35 AM
Last Post: Yoriz
Question PDF generation / edit SpongeB0B 2 2,122 Jul-28-2021, 05:59 AM
Last Post: SpongeB0B
  Not rounding to desired decimal places? pprod 2 2,614 Mar-05-2021, 11:11 AM
Last Post: pprod
  Calling Input for Random Generation ScaledCodingWarrior 1 1,907 Feb-02-2021, 07:27 PM
Last Post: bowlofred
  Decimal Rounding error project_science 4 2,825 Jan-06-2021, 03:14 PM
Last Post: project_science

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020