# Incorrect number of accepted selections by num\_accepted()

**URL:** <https://mworks.discourse.group/t/incorrect-number-of-accepted-selections-by-num-accepted/293>\
**Category:** Support\
**Created:** [October 26, 2018, 6:13pm UTC](https://mworks.discourse.group/t/incorrect-number-of-accepted-selections-by-num-accepted/293 "2018-10-26T18:13:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [October 26, 2018, 6:13pm UTC](https://mworks.discourse.group/t/incorrect-number-of-accepted-selections-by-num-accepted/293/1 "2018-10-26T18:13:47Z")

</div>

Hi Chris,

I’m trying to make an experiment which uses selection variables instead of range replicators to avoid resetting selection when I stop an experiment, as you suggested some time ago. Please see ‘Attention Sampling Protocol’ where it is implemented.

What I did is creating a list of all possible conditions in SOA\_location. In this variable, there are 16\*2 elements which correspond to 16 SOA by 2 target locations. To select from this variable, I made a selection variable, SOA\_location\_select. Selection from this variable is accepted in case of participants make a correct response (‘distributed\_success’) and rejected in other cases (‘distributed\_false\_alarm’, ‘distributed\_fixation\_break’, ‘distributed failure’).

The experiment will stop when number of accepted selection (num\_accepted() ) is equal to the size of SOA\_location, 32. However, it seems like the number provided by num\_accepted is not correct. Every time a trial is correctly completed, it should increase by 1 but instead in a lot of trials it increased by 2 (e.g. 1 3 4 5 6 8). This resulted in experiment stopped before reaching 32 trials because the num\_accepted() has reached 32. Do you have any idea what might caused this?

Best  
Tenri

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [October 29, 2018, 3:16pm UTC](https://mworks.discourse.group/t/incorrect-number-of-accepted-selections-by-num-accepted/293/2 "2018-10-29T15:16:16Z")

</div>

Hi Tenri,

I see that the “distributed\_pre\_acquire” state returns to “distributed\_start” when `not(fix_flag)` is true. When this happens, next\_selection is invoked again, without a preceding reject\_selections. Maybe this is the source of the discrepancy?

Chris

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [October 29, 2018, 6:36pm UTC](https://mworks.discourse.group/t/incorrect-number-of-accepted-selections-by-num-accepted/293/3 "2018-10-29T18:36:45Z")

</div>

Hi Chris,

I made a new state to which “distributed\_pre\_aquire” will go if not(fix\_flag) is true. Here, I don’t do next\_selection. However, the problem persists.

I think it is caused by faulty reject\_selection() somewhere in the code. To test, I made the selection method of SOA\_location\_select sequential. When I went to states which should reject selections (e.g. “distributed\_fixation\_break”, “distributed\_ignore”), MWorks went to the next selection values, instead of redoing the rejected selection values. After this, when I made a success (“distributed\_success”), num\_accepted() increased by more than 1 value.

Do you know how to solve this?

Thank you  
Tenri

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [October 29, 2018, 6:55pm UTC](https://mworks.discourse.group/t/incorrect-number-of-accepted-selections-by-num-accepted/293/4 "2018-10-29T18:55:01Z")

</div>

Because it was missing in the code I sent you, I also added reject\_selections() at “distributed\_ignore” when testing the above, so this should not be the problem.

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [October 29, 2018, 8:13pm UTC](https://mworks.discourse.group/t/incorrect-number-of-accepted-selections-by-num-accepted/293/5 "2018-10-29T20:13:32Z")

</div>

Hi Tenri,

I see the problem now. When used on a selection variable, reject\_selections implicitly invokes next\_selection. Since your “distributed\_start” state also invokes next\_selection (explicitly), the result is that you make two selections after every reject\_selections. Then, at the next accept\_selections, you accept both of these selections.

Looking back, I see that my “persistent selection” example led you astray on this point, as it invokes next\_selection explicitly at the start of every trial (but gets away with it, as it never invokes reject\_selections). Sorry about that!

I think the right approach is to remove the next\_selection call entirely and instead set SOA\_location\_select’s [advance\_on\_accept](https://mworks.github.io/documentation/latest/components/selection_variable.html#advance-on-accept) parameter to true, e.g.

```
selection SOA_location_select (
	values = 0:size(SOA_location) - 1
	selection = random_without_replacement
	advance_on_accept = true
	)

```

This will cause accept\_selections to invoke next\_selection automatically. (Also, you don’t need to call next\_selection after reset\_selection, as it will be called automatically the first time you use the value of SOA\_location\_select.)

Hopefully, that will fix things. If not, please let me know!

Chris

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [October 30, 2018, 11:18am UTC](https://mworks.discourse.group/t/incorrect-number-of-accepted-selections-by-num-accepted/293/6 "2018-10-30T11:18:04Z")

</div>

Hi Chris,

I tried what you suggested and the problem is solved now. Thank you!

Best  
Tenri

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [July 19, 2022, 9:39pm UTC](https://mworks.discourse.group/t/incorrect-number-of-accepted-selections-by-num-accepted/293/7 "2022-07-19T21:39:12Z")

</div>


