# fundamentals capstone 4.7

**URL:** <https://forum.kx.com/t/fundamentals-capstone-4-7/13889>\
**Category:** Academy Support\
**Tags:** imported\
**Created:** [April 13, 2024, 1:43pm UTC](https://forum.kx.com/t/fundamentals-capstone-4-7/13889 "2024-04-13T13:43:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kal8na](https://avatars.discourse-cdn.com/v4/letter/k/f14d63/32.png) [@Kal8na](https://forum.kx.com/u/Kal8na)\
**Post date:** [April 13, 2024, 1:43pm UTC](https://forum.kx.com/t/fundamentals-capstone-4-7/13889/1 "2024-04-13T13:43:38Z")

</div>

[https://learninghub.kx.com/forums/topic/fundamentals-capstone-4-7](https://learninghub.kx.com/forums/topic/fundamentals-capstone-4-7)

In 4.7 exercise I don't understand how to implement the code for it. maybe I don't understand what the question is asking. can you please explain this?

---

<div class="post-metadata">

**Author:** ![mmcparland](https://sea2.discourse-cdn.com/flex002/user_avatar/forum.kx.com/mmcparland/32/54_2.png) [@mmcparland](https://forum.kx.com/u/mmcparland)\
**Post date:** [April 15, 2024, 9:12am UTC](https://forum.kx.com/t/fundamentals-capstone-4-7/13889/2 "2024-04-15T09:12:03Z")

</div>

Hi @kal8na

Let me break down question 4.7 for you:

- Using your timeSeries dictionary that you created in ex 4.6, compare the correlation of edge against the correlation of qty then the correlation of edge against the correlation of numTrds. To do this you can use the keyword **cor** - [cor – corelation coefficient | Reference | kdb+ and q documentation - Kdb+ and q documentation (kx.com)](https://code.kx.com/q/ref/cor/) 
- Store this data in a dictionary called edgeCor with the keys being edge, qty and numTrds and the values being their correlation with the edge series.

There are a few different ways this can be done but using iteration is included as a suggestion.

Let me know if you require further assistance.

Thanks,

Megan

---

<div class="post-metadata">

**Author:** ![lestat-jin](https://sea2.discourse-cdn.com/flex002/user_avatar/forum.kx.com/lestat-jin/32/128_2.png) [@lestat-jin](https://forum.kx.com/u/lestat-jin)\
**Post date:** [June 19, 2024, 1:42pm UTC](https://forum.kx.com/t/fundamentals-capstone-4-7/13889/3 "2024-06-19T13:42:16Z")

</div>

just to borrow the thread as I’m stuck on this as well: so I managed to complete the task with script:

edgeCor:`edge`qty`numTrds!(1;cor[timeSeries[`edge];timeSeries[`qty]];cor[timeSeries[`edge];timeSeries[`numTrds]])

&nbsp;

the output is a dictionary with type 99h and values of 1 0.8059053 0.7830214

however it failed the section testing with 4.7 error: “edgeCor Has Correct Format”

&nbsp;

I didn’t implement it with iterators but I don’t think that is the reason it failed the test. not sure why it says incorrect format–do I need to output values in percentage terms (there is no way in Q to output a numeric in % without converting it into string first?)

&nbsp;

any ideas please? thanks!

---

<div class="post-metadata">

**Author:** ![lestat-jin](https://sea2.discourse-cdn.com/flex002/user_avatar/forum.kx.com/lestat-jin/32/128_2.png) [@lestat-jin](https://forum.kx.com/u/lestat-jin)\
**Post date:** [June 20, 2024, 12:03pm UTC](https://forum.kx.com/t/fundamentals-capstone-4-7/13889/4 "2024-06-20T12:03:49Z")

</div>

using a different approach and now it passed the section testing:

corKey:`edge`qty`numTrds

correlations:cor[timeSeries[edge]] each timeSeries[corKey]

edgeCor:corKey!correlations

&nbsp;

the results visually identical, though the earlier approach failed with 4.7 format testing:

edgeCor:`edge`qty`numTrds! (1;cor[timeSeries[`edge];timeSeries[`qty]];cor[timeSeries[`edge];timeSeries[`numTrds]])

would be good to understand why (cannot see how the testing function 4.7 written so cannot debug…) Thanks.

&nbsp;

P.S. apologies borrowing the thread, let me know if should create a separate discussion for this.

&nbsp;

---

<div class="post-metadata">

**Author:** ![lkerr2](https://sea2.discourse-cdn.com/flex002/user_avatar/forum.kx.com/lkerr2/32/57_2.png) [@lkerr2](https://forum.kx.com/u/lkerr2)\
**Post date:** [June 21, 2024, 4:17pm UTC](https://forum.kx.com/t/fundamentals-capstone-4-7/13889/5 "2024-06-21T16:17:58Z")

</div>

Hi,

Don't worry about jumping on the thread, it's good to have it on one thread to help others!

I ran your two solutions and then ran

```
type each edgeCor
```

on each.

And while the output dictionary looked the same for both outputs, using the input of "1" in your first attempt defaulted the types to:

```
edge | -7
qty | -9
numTrds| -9
```

when the correct types should be (and are in your second attempt)

```
edge | -9
qty | -9
numTrds| -9
```

Hope this helps!

Laura

---

<div class="post-metadata">

**Author:** ![lestat-jin](https://sea2.discourse-cdn.com/flex002/user_avatar/forum.kx.com/lestat-jin/32/128_2.png) [@lestat-jin](https://forum.kx.com/u/lestat-jin)\
**Post date:** [June 26, 2024, 6:46pm UTC](https://forum.kx.com/t/fundamentals-capstone-4-7/13889/6 "2024-06-26T18:46:02Z")

</div>

I see, should be 1.0 in the manual construction, thanks a lot!
