I'm currently trying to program a montecarlo sim to know the amount of unique objects acquired out of a collection in a given number of attempts. I have been using Eviews 10 for about 5 days and have no experience programming.

So far I have arrived at this

Code: Select all

`!reps = 1000`

!toy = 6

vector (!reps) right

scalar first = 0

scalar second = 1

scalar third = 2

scalar fourth = 3

scalar fifth = 4

scalar sixth = 5

for i = 1 to !reps

for !trial = 1 to 6

vector (!toy) toys

rnd(toys)

toys=@ceiling(toys*6)

mtos(toys, toyss)

series dtoyss = d(toyss)

dtoyss=@abs(dtoyss)

As far as I understand so far I've created a series that contains numbers from 0 to 5 depending on which toys were acquired that attempt. Now my problem lies in creating an if condition that checks each number in the series and marks a success for each draw if the number is unique thus a series containing (2, 0, 2, 3, 5 ,4) Would have 5 successes. I am not aware of any command that does this.

Maybe I'm approaching the problem wrong altogether, any help, suggestions or relevant examples would be deeply appreciated.

Sidenote: I'm running with the 'fors' commented because they also give me errors but that's a whole different issue.

Thanks.