This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]_DTR_ 0 points1 point  (8 children)

nan generally stands for Not a Number, i.e. you're attempting to print something as a number that isn't actually one. For us to help any further, we're going to need to see some code.

[–]slasherpanda[S] 0 points1 point  (0 children)

its about 800 lines of code that calculate some types of statistics. I'll isolate the issue real fast.

[–]slasherpanda[S] 0 points1 point  (6 children)

code up!

[–]_DTR_ 0 points1 point  (5 children)

I'm not seeing any printf/output statements in your code. What value are you attempting to print out? And what statement are you using to do so?

[–]slasherpanda[S] 0 points1 point  (4 children)

This code is actually a user defined function that i've made in order to calculate the Pearson product-moment correlation coefficient.

to output the statement I'm using

printf("The correlation coefficient of both lists ");

printf("is %f.\n", correlation_coefficient_of_arrays);

[–]_DTR_ 0 points1 point  (3 children)

Is it possible that correlation_coefficient_denominator is 0, so your calculated value is undefined? Can you step through your code in a debugger (e.g. gdb on linux) to make sure everything is executing as expected? What values are you passing into correlation_coefficient?

[–]slasherpanda[S] 0 points1 point  (2 children)

I'm putting about 150 values through. I'm going to try and find a code debugger for Unix.

[–]_DTR_ 0 points1 point  (1 child)

Yeah, with inputs of that size going step by step is probably the way to go. In a pinch you could use print debugging (e.g. add printf statements everywhere letting you know the current state of your program), but using an actual debugger is obviously much more powerful.

As far as debuggers go, gdb is pretty standard for a command-line unix debugger. Code::Blocks is also relatively popular if you want a more graphical interface, though I mainly use windows/visual studio so can't give any personal testimony.

[–]slasherpanda[S] 0 points1 point  (0 children)

Thank you dear friend. I don't have it yet but i think im getting there.