dimanche 27 novembre 2016

Generating Arrays of Random Values Influenced by Integers in Julia

We begin with

sets=[0.306894 0.564316 0.835714; 0.962995 0.97134 0.627331; 0.739529 0.665181 0.279065; 0.598537 0.0537966 0.918484; 0.220525 0.554764 0.294359]

shown in table form:

╔══════════╦═══════════╦══════════╗
║   Set1   ║   Set2    ║   Set3   ║
╠══════════╬═══════════╬══════════╣
║ 0.306894 ║ 0.564316  ║ 0.835714 ║
║ 0.962995 ║ 0.971345  ║ 0.627331 ║
║ 0.739529 ║ 0.665181  ║ 0.279065 ║
║ 0.598537 ║ 0.0537966 ║ 0.918484 ║
║ 0.220525 ║ 0.554764  ║ 0.294359 ║
╚══════════╩═══════════╩══════════╝

and

influencers=[9,5,9,4,7]

shown in table form:

╔═════════════╗
║ Influencers ║
╠═════════════╣
║           9 ║
║           5 ║
║           9 ║
║           4 ║
║           7 ║
╚═════════════╝

where influencers specifies how many times a process will be repeated (will be explained further down).

We will then create an array of random values using rand() and Normal() from the Distributions package.

The first column of the array will be five random values partly based on the first value in Set 1 (0.306894)

rand(Normal(0,.15+0.306894),5)

The second column of the array will be five random values partly based on the second value in Set 1 (0.962995).

This should be done until the last value in Set 1 (0.220525) is used to generate 5 random values.

Before moving on to using the values from Set 2, this process must be repeated (with new random numbers being generated in each repetition) by the corresponding number in "influencers". As the first value in influencers is 9, the process would be repeated 9 times, generating an array of 5 rows by 5*9=45 columns.

This would be performed until all values in sets were used. The data impacted by set 2 would be a 5x25 as there are five values in set 5 and the second value in "influencers" is 5.

The final output would be a 5x170 array with the general appearance of:

╔══════════╦═══════════╦═════╦══════════╦══════════╦═════╗
║   out1   ║   out2    ║ ... ║   out9   ║  out10   ║ ... ║
╠══════════╬═══════════╬═════╬══════════╬══════════╬═════╣
║ 0.617515 ║ 0.840251  ║     ║ 0.433632 ║ 0.259546 ║     ║
║ 0.302227 ║ 0.972178  ║     ║ 0.683352 ║ 0.567368 ║     ║
║ 0.788301 ║ 0.607621  ║     ║ 0.562016 ║ 0.424742 ║     ║
║ 0.195857 ║ 0.0176129 ║     ║ 0.251916 ║ 0.406313 ║     ║
║ 0.695097 ║ 0.168849  ║     ║ 0.993037 ║ 0.760426 ║     ║
╚══════════╩═══════════╩═════╩══════════╩══════════╩═════╝

where out1 through out9 would be based on set 1 and out10 would be where the data generated from set 2 would begin.

Can anyone point me in the right direction for how to achieve this? If it is possible to keep the output in this format, that would be best as the coding for future calculations will be simplified significantly.

Thank you for your help!

-Alejandro Braun




Aucun commentaire:

Enregistrer un commentaire