Skip to content

In this task I want to make an array and selected some indexes from it randomly, and assign those indexes, values that should be in specific bound and finally the summation of the values must be One.

Notifications You must be signed in to change notification settings

alirezap1376/SumOne

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

Line 1 to 3: import our useful libraries.
Line 5: determine how many elements should be select from your vector.
Line 6: determine the length of your vector.
Line 7 to 8: determine minimum and maximum bound of your random values.
Line 10: make a vector 
Line 12: make random values, that you decided bound and number of them in previous steps.
Line 14 to 15: round your random values to 2 digits.
Line 17 to 20: in this loop you check summation of your random values. if it is less than 1,you must add to the last value, the amount of difference between 1 and vectore's summation. else, you must minus to the last value, the amount of difference between 1 and vectore's summation.
Line 22: from your original vector, you decide some indexes that you decide number of them in 'Line 5'
Line 24 to 25: for indexes that selected in previous step, you assign their values.

About

In this task I want to make an array and selected some indexes from it randomly, and assign those indexes, values that should be in specific bound and finally the summation of the values must be One.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages