cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

SELECT DIFFERENT

ppal
17-Peridot

SELECT DIFFERENT

ppal_0-1665549033106.png

 

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:ppal)

Here is a utility function. The input is a vector of scalar values of any length. The return value is that vector element which occurs least often. If there are several, the first one to appear is chosen.

Werner_E_0-1665573446917.png

And here is a function working just for your special case of a three element vector with one single value

Werner_E_0-1665574320539.png

 

View solution in original post

15 REPLIES 15
ttokoro
20-Turquoise
(To:ppal)

image.pngimage.pngimage.png

ppal
17-Peridot
(To:ttokoro)

Hi

 

Can this be done within a tolerance band?

 

If I had 

ppal_0-1665627898742.png

 

I'd like to select 15 000

 

ttokoro
20-Turquoise
(To:ppal)

If A[0<>A[1<>A[2 and you want max. middle or mini also can select after else instead max(A) but sort(A)[1 and min(A).

image.pngimage.pngimage.pngimage.pngimage.png

Werner_E
25-Diamond I
(To:ttokoro)

I guess your approach is not what ppal is looking for. Maybe you misunderstood the intention.

If no two values are equal, not the largest value should be returned but the value which is farthest apart from the other two.

So with input 9, 14, 15 your function would return 15 while it should return 9.

ttokoro
20-Turquoise
(To:Werner_E)

 

Thanks, I understand what he wants.

image.pngimage.pngimage.png

Werner_E
25-Diamond I
(To:ttokoro)

Have you tested your function with a couple of triples? I guess its not doing what was demanded.

Just try the original set of (10; 9; 15).

 

ttokoro
20-Turquoise
(To:Werner_E)

image.pngimage.png

Werner_E
25-Diamond I
(To:ttokoro)

Try (1,2,10). Your f3 would return 2 and not 10.

I don't think that the mean is of much help in this task.

 

After sorting the values the only thing important is, which of the two outer elements is farther away from the center element. And thats exactly what my functions do -> https://community.ptc.com/t5/Mathcad/SELECT-DIFFERENT/m-p/830256/highlight/true#M203207

Werner_E
25-Diamond I
(To:ppal)

Here is a modified selectMin3 (yes, well, the name was chosen misleading, you should change it).

Werner_E_1-1665659009504.png

 

 

Werner_E
25-Diamond I
(To:Werner_E)

OK, with the modification done to selectMin3 the approach was unnecessary complicated.

A more straightforward approach is shown here, using just one if-else (function or statement - your choice)

Werner_E_0-1665660772004.png

 

ppal
17-Peridot
(To:Werner_E)

I am using this now. It is doing what I wanted to do. Thank you.

LucMeekes
23-Emerald III
(To:ppal)

I wonder if this simple implementation works satisfactorily:

LucMeekes_0-1665956509879.png

Some results:

LucMeekes_1-1665956563361.png

Success!
Luc

Werner_E
25-Diamond I
(To:LucMeekes)

Sophisticated! 🙂

ppal
17-Peridot
(To:LucMeekes)

Yes! - Few roads now leading to Rome.

Werner_E
25-Diamond I
(To:ppal)

Here is a utility function. The input is a vector of scalar values of any length. The return value is that vector element which occurs least often. If there are several, the first one to appear is chosen.

Werner_E_0-1665573446917.png

And here is a function working just for your special case of a three element vector with one single value

Werner_E_0-1665574320539.png

 

Announcements

Top Tags