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
#6
Thank you so much @Yoriz. It works well now. But, it deletes that 0.0 now completely and reduces the number of the index. For example , My array has to include 10 index. Since there is one 0 in one of the indexes ,now the code removes that 0 and the dimension of array becomes 9. However , I should keep the same dimension. How can I do that ? Thank you

Output:
[0.11, 0.04, 0.2, 0.02, 0.11, 0.42, 0.02, 0.05, 0.03]
Reply


Messages In This Thread
RE: Random data generation sum to 1 by rounding - by juniorcoder - Oct-03-2021, 12:59 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  need help rounding joseph202020 7 1,520 Feb-21-2023, 08:13 PM
Last Post: joseph202020
  Node Flow Generation in Python Linenloid 0 724 Feb-21-2023, 07:09 PM
Last Post: Linenloid
  Allure Report Generation rotemz 0 893 Jan-24-2023, 08:30 PM
Last Post: rotemz
  from numpy array to csv - rounding SchroedingersLion 6 2,513 Nov-14-2022, 09:09 PM
Last Post: deanhystad
  Why doesnt chunk generation work? LotosProgramer 1 2,042 Apr-02-2022, 08:25 AM
Last Post: deanhystad
  Rounding issue kmll 1 1,541 Oct-08-2021, 10:35 AM
Last Post: Yoriz
Question PDF generation / edit SpongeB0B 2 2,183 Jul-28-2021, 05:59 AM
Last Post: SpongeB0B
  Not rounding to desired decimal places? pprod 2 2,673 Mar-05-2021, 11:11 AM
Last Post: pprod
  Calling Input for Random Generation ScaledCodingWarrior 1 1,962 Feb-02-2021, 07:27 PM
Last Post: bowlofred
  Decimal Rounding error project_science 4 2,917 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