cancel
Showing results for
Did you mean:
cancel
Showing results 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

6-Contributor

## for some vector [25 15 23 20 .. n ] i want to find if the adjacent values exceed 1.2 of each other

Hi,

I want to write a code where for some vector [25 15 23 20 .. n ] i want to find if the ratios of the adjacent values exceed 1.2 of each other. The output result would be like "Yes" or "No". how do i go about doing that?

For example: for vector [15 25 20], because 25/15>1.2, I want the answer as "Yes".

But I would also want the same answer "Yes" if it was [25 15 20] because in this case also for the adjacent values 25/15>1.2.

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
24-Ruby V
(To:Werner_E)

Here is a variant which returns just a single answer:

7 REPLIES 7
24-Ruby V
(To:aaaaaaaa)

Maybe a custom command like the following will do the job:

In case you are using Prime, use "else" instead of "otherwise".

6-Contributor
(To:Werner_E)

I'm so sorry that i mistyped the question.

For example: for vector [15 25 20], because 25/15>1.2, I want the answer as "Yes".

But I would also want the same answer "Yes" if it was [25 15 20] because in this case also for the adjacent values 25/15>1.2.

24-Ruby V
(To:aaaaaaaa)

OK, so its the Ratio, not the difference.

And what do you expect as a result? Just one single "Yes" or "No" for the whole Vector if the Ratio of any adjacent pair exceeds 1.2, or a "Yes" or "No" for every triple (or pair?) in the Vector?

If the latter - what about the ends? Do you expect an  n x 1 vector, an  (n-1) x 1 vector or an  (n-2) x 1 vector as a result?

24-Ruby V
(To:Werner_E)

Here is a variant which returns just a single answer:

6-Contributor
(To:Werner_E)

Just one single "Yes" if the Ratio of all adjacent pair does not exceeds 1.2, and just a single "No" if the Ratio of any adjacent pair does not exceeds 1.2.

Thank you.

24-Ruby V
(To:aaaaaaaa)

OK, so you would have to exchange "Yes" and "No" in my last attempt.

Otherwise it should do what you demand.

6-Contributor
(To:Werner_E)

Thanks I was looking for the algorithm on how i should work it out;; your last attempt helped me a bunch!! thanks a lot!

Announcements
Top Tags