Timeline for Count gives different results depending on specification
Current License: CC BY-SA 3.0
11 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Nov 30, 2016 at 6:11 | vote | accept | Castle | ||
Nov 29, 2016 at 21:47 | comment | added | corey979 |
You are facing numerical artifacts; MemberQ[Table[i, {i, 0, k*h1, h1}], 0.95] gives False , because 0.01*95 =!= 0.95 -- see here. You could do round2[x_, n_] := Floor[10^n x]/10^n; tabelsav2 = round2[tabelsav, 2]; k = 1000; h1 = 1/100; then create tabelmod (run N on it afterwards) and see that there are 4. occurences of 0.95 .
|
|
Nov 29, 2016 at 21:42 | vote | accept | Castle | ||
Nov 30, 2016 at 6:11 | |||||
Nov 29, 2016 at 21:12 | answer | added | Bob Hanlon | timeline score: 3 | |
Nov 29, 2016 at 20:47 | history | edited | Castle | CC BY-SA 3.0 |
added 696 characters in body
|
Nov 29, 2016 at 20:35 | comment | added | Castle |
I used round2[x_, n_] := Floor[10^n x]/10^n // N and tabelsav2 = round2[tabelsav, 2] to produce the table i want... BUT now its even worse... now the 0.95 doesnt show up in the loop! It does however if i specifically ask it through Count... what gives?
|
|
Nov 29, 2016 at 20:23 | review | Close votes | |||
Nov 30, 2016 at 18:54 | |||||
Nov 29, 2016 at 20:01 | comment | added | corey979 |
In your demo2 you take the values to be counted from tabelsav itself, i.e. values really existing in the list. Look closely - you'll see there's no 0.95 - there's an 0.9500000000000001 , which is not the same. So, Count[tabelsav[[All, 1]], 0.95] correctly says there's no 0.95 .
|
|
Nov 29, 2016 at 19:59 | comment | added | march |
This is likely a precision issue. You are trying to mach 0.95, but 0.9500000000000001 ` shows up in your list.
|
|
Nov 29, 2016 at 19:57 | history | edited | corey979 | CC BY-SA 3.0 |
added 1311 characters in body; edited tags
|
Nov 29, 2016 at 19:50 | history | asked | Castle | CC BY-SA 3.0 |