Inexact numbers as keys in Association?Dr. StrangeNumbers or: How I Learned to Stop Worrying and Love Floating Point ArithmeticFractional Keys in AssociationsReplace and AssociationWrong Limit[…] for inexact expressionsPicking out multiple keys from an arrayUsing Case to pull Keys and Values out of a nested AssociationPattern matching Association in rulesCreating dataset from list of ragged associations with defaults for missing keyshow to count or extract Cases out of list of association that matches patternRename Keys in Nested AssociationExtracting the graph of Keys in nested Associations

Knowledge-based authentication using Domain-driven Design in C#

Why was the shrink from 8″ made only to 5.25″ and not smaller (4″ or less)

What's the meaning of "Sollensaussagen"?

Sums of two squares in arithmetic progressions

Why do I get negative height?

What reasons are there for a Capitalist to oppose a 100% inheritance tax?

How to remove border from elements in the last row?

Venezuelan girlfriend wants to travel the USA to be with me. What is the process?

Blending or harmonizing

Ambiguity in the definition of entropy

Notepad++ delete until colon for every line with replace all

Are British MPs missing the point, with these 'Indicative Votes'?

What are the G forces leaving Earth orbit?

One verb to replace 'be a member of' a club

How exploitable/balanced is this homebrew spell: Spell Permanency?

Can someone clarify Hamming's notion of important problems in relation to modern academia?

files created then deleted at every second in tmp directory

How to compactly explain secondary and tertiary characters without resorting to stereotypes?

Avoiding the "not like other girls" trope?

In Bayesian inference, why are some terms dropped from the posterior predictive?

How seriously should I take size and weight limits of hand luggage?

My ex-girlfriend uses my Apple ID to log in to her iPad. Do I have to give her my Apple ID password to reset it?

What do you call someone who asks many questions?

Does Dispel Magic work on Tiny Hut?



Inexact numbers as keys in Association?


Dr. StrangeNumbers or: How I Learned to Stop Worrying and Love Floating Point ArithmeticFractional Keys in AssociationsReplace and AssociationWrong Limit[…] for inexact expressionsPicking out multiple keys from an arrayUsing Case to pull Keys and Values out of a nested AssociationPattern matching Association in rulesCreating dataset from list of ragged associations with defaults for missing keyshow to count or extract Cases out of list of association that matches patternRename Keys in Nested AssociationExtracting the graph of Keys in nested Associations













4












$begingroup$


Can someone explain me how Mathematica's Associations behave with inexact numbers as keys:



<| 0.22499999999999964` -> a |> [0.22499999999999965`]


and



<| 0.22499999999999964` -> a |> [0.22499999999999961`] 


both give the value a, whereas



 <| 0.22499999999999964` -> a |> [0.22499999999999966`] gives Missing as an answer.









share|improve this question











$endgroup$







  • 2




    $begingroup$
    Looks like this thing, but with associations. Why do you need to use inexact numbers as keys?
    $endgroup$
    – J. M. is slightly pensive♦
    2 days ago






  • 4




    $begingroup$
    "Can someone explain me how Mathematica's Associations behave [...]?" They behave badly. Don't do that.
    $endgroup$
    – Henrik Schumacher
    2 days ago











  • $begingroup$
    Association is the name of the function in Mathematica, so I am not sure what was productive about the edit I just rolled back.
    $endgroup$
    – J. M. is slightly pensive♦
    yesterday















4












$begingroup$


Can someone explain me how Mathematica's Associations behave with inexact numbers as keys:



<| 0.22499999999999964` -> a |> [0.22499999999999965`]


and



<| 0.22499999999999964` -> a |> [0.22499999999999961`] 


both give the value a, whereas



 <| 0.22499999999999964` -> a |> [0.22499999999999966`] gives Missing as an answer.









share|improve this question











$endgroup$







  • 2




    $begingroup$
    Looks like this thing, but with associations. Why do you need to use inexact numbers as keys?
    $endgroup$
    – J. M. is slightly pensive♦
    2 days ago






  • 4




    $begingroup$
    "Can someone explain me how Mathematica's Associations behave [...]?" They behave badly. Don't do that.
    $endgroup$
    – Henrik Schumacher
    2 days ago











  • $begingroup$
    Association is the name of the function in Mathematica, so I am not sure what was productive about the edit I just rolled back.
    $endgroup$
    – J. M. is slightly pensive♦
    yesterday













4












4








4





$begingroup$


Can someone explain me how Mathematica's Associations behave with inexact numbers as keys:



<| 0.22499999999999964` -> a |> [0.22499999999999965`]


and



<| 0.22499999999999964` -> a |> [0.22499999999999961`] 


both give the value a, whereas



 <| 0.22499999999999964` -> a |> [0.22499999999999966`] gives Missing as an answer.









share|improve this question











$endgroup$




Can someone explain me how Mathematica's Associations behave with inexact numbers as keys:



<| 0.22499999999999964` -> a |> [0.22499999999999965`]


and



<| 0.22499999999999964` -> a |> [0.22499999999999961`] 


both give the value a, whereas



 <| 0.22499999999999964` -> a |> [0.22499999999999966`] gives Missing as an answer.






associations machine-precision






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited yesterday









J. M. is slightly pensive♦

98.9k10311467




98.9k10311467










asked 2 days ago









Ali HashmiAli Hashmi

5,71931432




5,71931432







  • 2




    $begingroup$
    Looks like this thing, but with associations. Why do you need to use inexact numbers as keys?
    $endgroup$
    – J. M. is slightly pensive♦
    2 days ago






  • 4




    $begingroup$
    "Can someone explain me how Mathematica's Associations behave [...]?" They behave badly. Don't do that.
    $endgroup$
    – Henrik Schumacher
    2 days ago











  • $begingroup$
    Association is the name of the function in Mathematica, so I am not sure what was productive about the edit I just rolled back.
    $endgroup$
    – J. M. is slightly pensive♦
    yesterday












  • 2




    $begingroup$
    Looks like this thing, but with associations. Why do you need to use inexact numbers as keys?
    $endgroup$
    – J. M. is slightly pensive♦
    2 days ago






  • 4




    $begingroup$
    "Can someone explain me how Mathematica's Associations behave [...]?" They behave badly. Don't do that.
    $endgroup$
    – Henrik Schumacher
    2 days ago











  • $begingroup$
    Association is the name of the function in Mathematica, so I am not sure what was productive about the edit I just rolled back.
    $endgroup$
    – J. M. is slightly pensive♦
    yesterday







2




2




$begingroup$
Looks like this thing, but with associations. Why do you need to use inexact numbers as keys?
$endgroup$
– J. M. is slightly pensive♦
2 days ago




$begingroup$
Looks like this thing, but with associations. Why do you need to use inexact numbers as keys?
$endgroup$
– J. M. is slightly pensive♦
2 days ago




4




4




$begingroup$
"Can someone explain me how Mathematica's Associations behave [...]?" They behave badly. Don't do that.
$endgroup$
– Henrik Schumacher
2 days ago





$begingroup$
"Can someone explain me how Mathematica's Associations behave [...]?" They behave badly. Don't do that.
$endgroup$
– Henrik Schumacher
2 days ago













$begingroup$
Association is the name of the function in Mathematica, so I am not sure what was productive about the edit I just rolled back.
$endgroup$
– J. M. is slightly pensive♦
yesterday




$begingroup$
Association is the name of the function in Mathematica, so I am not sure what was productive about the edit I just rolled back.
$endgroup$
– J. M. is slightly pensive♦
yesterday










1 Answer
1






active

oldest

votes


















10












$begingroup$

Lookups with inexact numbers behave like other lookups: they use hashing. We can check that the results are consistent with what Hash does.



vals = 0.22499999999999961`, 0.22499999999999964`, 
0.22499999999999965`, 0.22499999999999966`;
Hash /@ vals

(* Out[11]= 1879126079618645156, 1879126079618645156,
1879126079618645156, 5861724109654749116 *)


When hashing approximate values, there are going to be sharp boundaries (discontinuities, in effect). This is a tradeoff between having "very" close neighbors hash to the same value, and maintaining transitivity.






share|improve this answer









$endgroup$













    Your Answer





    StackExchange.ifUsing("editor", function ()
    return StackExchange.using("mathjaxEditing", function ()
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
    );
    );
    , "mathjax-editing");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "387"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f194309%2finexact-numbers-as-keys-in-association%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    10












    $begingroup$

    Lookups with inexact numbers behave like other lookups: they use hashing. We can check that the results are consistent with what Hash does.



    vals = 0.22499999999999961`, 0.22499999999999964`, 
    0.22499999999999965`, 0.22499999999999966`;
    Hash /@ vals

    (* Out[11]= 1879126079618645156, 1879126079618645156,
    1879126079618645156, 5861724109654749116 *)


    When hashing approximate values, there are going to be sharp boundaries (discontinuities, in effect). This is a tradeoff between having "very" close neighbors hash to the same value, and maintaining transitivity.






    share|improve this answer









    $endgroup$

















      10












      $begingroup$

      Lookups with inexact numbers behave like other lookups: they use hashing. We can check that the results are consistent with what Hash does.



      vals = 0.22499999999999961`, 0.22499999999999964`, 
      0.22499999999999965`, 0.22499999999999966`;
      Hash /@ vals

      (* Out[11]= 1879126079618645156, 1879126079618645156,
      1879126079618645156, 5861724109654749116 *)


      When hashing approximate values, there are going to be sharp boundaries (discontinuities, in effect). This is a tradeoff between having "very" close neighbors hash to the same value, and maintaining transitivity.






      share|improve this answer









      $endgroup$















        10












        10








        10





        $begingroup$

        Lookups with inexact numbers behave like other lookups: they use hashing. We can check that the results are consistent with what Hash does.



        vals = 0.22499999999999961`, 0.22499999999999964`, 
        0.22499999999999965`, 0.22499999999999966`;
        Hash /@ vals

        (* Out[11]= 1879126079618645156, 1879126079618645156,
        1879126079618645156, 5861724109654749116 *)


        When hashing approximate values, there are going to be sharp boundaries (discontinuities, in effect). This is a tradeoff between having "very" close neighbors hash to the same value, and maintaining transitivity.






        share|improve this answer









        $endgroup$



        Lookups with inexact numbers behave like other lookups: they use hashing. We can check that the results are consistent with what Hash does.



        vals = 0.22499999999999961`, 0.22499999999999964`, 
        0.22499999999999965`, 0.22499999999999966`;
        Hash /@ vals

        (* Out[11]= 1879126079618645156, 1879126079618645156,
        1879126079618645156, 5861724109654749116 *)


        When hashing approximate values, there are going to be sharp boundaries (discontinuities, in effect). This is a tradeoff between having "very" close neighbors hash to the same value, and maintaining transitivity.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 2 days ago









        Daniel LichtblauDaniel Lichtblau

        47.5k277165




        47.5k277165



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Mathematica Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid …


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f194309%2finexact-numbers-as-keys-in-association%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Does high air pressure throw off wheel balance? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Should we be closing questions more regularly?How much should I inflate my tire?Which tire pressure is right for my 2008 Toyota Yaris's front tires?Should I let air out of my tires?Tire Pressure Adjustments When NeededRadial tires: Do they bulge at too high pressure?Cold weather tire pressure adjustmentHow does tire pressure vary with altitude?Why does a tire have the same air pressure when mounted on the car and when not?What does tire size have to do with the capabilities of an air compressor?Tire pressure with tires on vs off the car

            Magento2 - How to hide price filter only in specific categories?Multiselect price filter attribute in layered navigationhide only some categories from layered navigation in magentoRemove Price Filter on certain categoriescustomize layered price filter?Hide Price for a particular customer groupPrice filter in layered navigation not working correctly with price including tax in magento 2.2.3Magento 2 how to hide attribute at Layered navigation?Magento 2. how to hide price only for specific categoriesMagento 2 How can I hide the price and total from cart and checkout summary?Magento2: Can we add navigation layered filter like price filter for other attribute?

            Inventory management after order created via rest API in Magento 2.x version ( without cart)Magento - Create order using REST APILocalization for Cart/Quote APIs doesn't work properly in magento 2Magento 1.9 - Create order using REST APIPLacing Order Magento 2.1 REST APIREST API accessible without authorizationMagento 2.2 Inventory not getting decreased when orders are created using REST APIWhat is the usage of itemId inside Update inventory REST API?Get category meta tags via REST APIGet cart info REST APIAdding a grouped product to cart via the rest api