How to refresh cached image ONCE

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jorge

    #16
    Re: How to refresh cached image ONCE

    On Jul 19, 6:07 pm, Dr J R Stockton <j...@merlyn.de mon.co.ukwrote:
    >
    No, for two reasons.  The generator is not necessarily 64-bit or even
    53-bit.  In my js-randm.htm, "MSIE 6 and 7 show 53 bits; Firefox 2.0.0.3
    shows 52 bits; Opera 9.21 shows 31 bits; Safari 3.1 shows 31 bits."
    And, as the generator is only pseudo-random, it should not repeat until
    after a full cycle.
    >
    Yes you're right. In fact Safari's PRNG always repeats at n=
    2,147,483,645 (-2^31) (don't tell Thomas :-)
    What does that page report (for various browsers?) on your Mac?
    >
    "Apparent resolution is at least 30 bits."

    Thanks,
    --Jorge.

    Comment

    • Jorge

      #17
      Re: How to refresh cached image ONCE

      On Jul 19, 6:07 pm, Dr J R Stockton <j...@merlyn.de mon.co.ukwrote:
      >
      What does that page report (for various browsers?) on your Mac?
      >
      On a Mac :

      Webkit r34974: "Apparent resolution is at least 30 bits."
      Safari 3.1.2: "Apparent resolution is at least 30 bits."

      Opera 9.51: "Apparent resolution is at least 31 bits."

      Navigator 9.0.0.3: "Apparent resolution is at least 52 bits."
      Camino 1.6.1: "Apparent resolution is at least 52 bits."
      FF 2.0.0.16: "Apparent resolution is at least 52 bits."
      FF 3.1: "Apparent resolution is at least 52 bits."

      IE 5.2: "Apparent resolution is at least 53 bits."

      iCab 3.0.5 : "Apparent resolution is at least 58 bits."

      --Jorge

      Comment

      • Jorge

        #18
        Re: How to refresh cached image ONCE

        On Jul 19, 6:07 pm, Dr J R Stockton <j...@merlyn.de mon.co.ukwrote:
        What does that page report (for various browsers?) on your Mac?

        On a Mac :
        Webkit r34974: "Apparent resolution is at least 30 bits."
        Safari 3.1.2: "Apparent resolution is at least 30 bits."

        Opera 9.51: "Apparent resolution is at least 31 bits."

        Navigator 9.0.0.3: "Apparent resolution is at least 52 bits."
        Camino 1.6.1: "Apparent resolution is at least 52 bits."
        FF 2.0.0.16: "Apparent resolution is at least 52 bits."
        FF 3.1: "Apparent resolution is at least 52 bits."

        IE 5.2.3: "Apparent resolution is at least 53 bits."

        iCab 3.0.5: "Apparent resolution is at least 58 bits."

        --Jorge

        Comment

        • Dr J R Stockton

          #19
          Re: How to refresh cached image ONCE

          In comp.lang.javas cript message <c9681dae-4958-410e-993b-86bb9eeddd00@l4
          2g2000hsc.googl egroups.com>, Sat, 19 Jul 2008 12:37:21, Jorge
          <jorge@jorgecha morro.composted :
          >On Jul 19, 6:07 pm, Dr J R Stockton <j...@merlyn.de mon.co.ukwrote:
          >What does that page report (for various browsers?) on your Mac?
          ...
          >iCab 3.0.5: "Apparent resolution is at least 58 bits."
          That one was initially rather unexpected, since Math.random() is
          supposed to return an evenly-distributed IEEE Double with an effective
          53-bit mantissa, and the best previously seen or reported was 53 bits.

          ISO/IEC 16262 only requires that the result of Math.random() be evenly
          distributed, not that the resolution be independent of the value.

          It appears that other browsers in effect mask the output of the
          (64-bit?) PRNG to 53 bits before converting to Double, while iCab does
          that only within the conversion itself.

          It seems undesirable for there to be unnecessary numerical differences
          between browsers; if anyone has contact with those writing future
          specifications, then I suggest that they ask for the future spec to have
          this uncertainty removed. While iCab in a sense has better randomness,
          ISTM that uniformity would be preferable.

          The function you observed, Resol, is now Resol1; new Resol3 is similar
          but uses only randoms >= 0.5.

          --
          (c) John Stockton, nr London, UK. ?@merlyn.demon. co.uk Turnpike v6.05 MIME.
          Web <URL:http://www.merlyn.demo n.co.uk/- FAQish topics, acronyms, & links.
          Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
          Do not Mail News to me. Before a reply, quote with ">" or "" (SonOfRFC1036)

          Comment

          • Jorge

            #20
            Re: How to refresh cached image ONCE

            On Jul 20, 7:32 pm, Dr J R Stockton <j...@merlyn.de mon.co.ukwrote:
            >
            The function you observed, Resol, is now Resol1; new Resol3 is similar
            but uses only randoms >= 0.5.
            >
            John,

            I have retouched your resol1() a little bit. Now it receives a
            parameter p, and it doesn't return until the higher resolution found
            remains unchanged for p iterations of the loop. It gives higher
            readings now.

            I have also written a bits() function that finds what is the smaller
            power of 2 for which it's true that (2^x) === ((2^x)+1). I think that
            that must be the size of the mantissa, or not ?

            See it here : http://tinyurl.com/68d9br

            These are the numbers I get :

            IE 5.2.3 : 53, 53.
            FF2, FF3 : 52, 53.
            Safari : 30, 53.
            Opera 9.51 : 31, 53.
            iCab 3.0.5 : 63, 53.

            But I don't understand why those numbers are different. And, if the
            mantissa is 53 bits (iCab), how can, why does resol1() give 63 ?

            Here's the code :

            <script>
            window.onload= function () {
            var resol1= (function (p) {
            var x, t, max= 0, i= p;
            while (i) {
            t= 0, x= Math.random();
            while ((x*= 2)%1 0) { // shift left until empty
            t++;
            }
            if (t max) {
            max= t, i= p;
            } else {
            i--;
            }
            }
            return max;
            })(1e4);

            var bits= (function () {
            var x, i= 0;
            do {
            x= Math.pow(2,++i) ;
            } while (x !== (x+1))
            return i;
            })();

            var test= Math.pow(2,bits );
            var text= "resol1() : Maximum resolution is at least "+resol1+"
            bits.<br>";
            text+= "bits() : "+bits+" -In this browser "+(test+1)+ " ===
            1+"+test;

            (document.body. appendChild(
            document.create Element(
            'h2'))).innerHT ML= text;

            };
            </script>

            Thanks,
            --Jorge.

            Comment

            • Jorge

              #21
              Re: How to refresh cached image ONCE

              On Jul 21, 3:35 pm, "C. (http://symcbean.blogsp ot.com/)"
              <colin.mckin... @gmail.comwrote :
              >
              I can get to go back to the server even though the image is cached if
              I put it in an iframe with src= the image URL then
              document.getEle mentById("MyIfr ame").contentWi ndow.location.r eload();
              >
              If just a plain location.reload () won't do, if setting img.src+= "?
              something" won't do either, then that sounds like a Good Idea...

              --Jorge.

              Comment

              • Dr J R Stockton

                #22
                Re: How to refresh cached image ONCE

                In comp.lang.javas cript message <0d5ff528-59a3-4bb7-8f48-5df465dce82c@i7
                6g2000hsf.googl egroups.com>, Mon, 21 Jul 2008 06:27:24, Jorge
                <jorge@jorgecha morro.composted :
                >I have also written a bits() function that finds what is the smaller
                >power of 2 for which it's true that (2^x) === ((2^x)+1). I think that
                >that must be the size of the mantissa, or not ?
                We know that 2^53 is 900719925474099 2. A Number, being an IEEE Double
                and having a 53-bit mantissa, cannot represent 900719925474099 3. But
                it's not yet absolutely clear to me whether 2^53+1 MUST evaluate to 2^53
                and not to 2^53+2.

                It is certain that JavaScript uses IEEE Doubles, and that those consist
                of one sign bit, eleven biased-exponent bits, a non-stored "1" bit
                leading the mantissa, and fifty-two more mantissa bits. 2^53+1 is the
                lowest integer requiring MSB...LSB to be at least 54 bits; the lowest
                which cannot be stored exactly.


                >These are the numbers I get :
                >
                >IE 5.2.3 : 53, 53.
                >FF2, FF3 : 52, 53.
                >Safari : 30, 53.
                >Opera 9.51 : 31, 53.
                >iCab 3.0.5 : 63, 53.
                >
                >But I don't understand why those numbers are different. And, if the
                >mantissa is 53 bits (iCab), how can, why does resol1() give 63 ?
                I'm not entirely sure, to +/- 1 in the result, whether the algorithms
                are ideal. But there are clearly three cases : about 31, about 52, and
                about 63.

                I suppose that "about 31" are those in which 32-bit processing is
                involved - probably a 32-bit generator (which will repeat after 2*32 (or
                2^32-1) values). Clearly, given the integer operations such as X|Y and
                the use of Number for storage, the JavaScript engine must have
                interconverters .

                The others probably, but not necessarily, use a 64-bit integer pseudo-
                random binary sequence generator of the form
                U[n] = (U[n-1]*vast + 1) mod 2^64.

                Note that the FPU of a PC has the "comp" type, a 64-bit integer, and the
                "Extended" type, with a genuine 64-bit mantissa; and a PC can do 64-bit
                integer arithmetic either with comp or with a pair of 32-bit integers.
                So the system programmer can calculate U[n], put it into the mantissa of
                an Extended with suitable exponent, and ask for conversion to the Double
                equivalent. In the conversion, U[n] will lose all its leading zeroes,
                and then as many trailing bits as cannot fit into the 53 places
                available. The value of the least preserved bit will depend on the
                value of the Random generated.

                However, that means that the resolution of Math.random depends on the
                value generated - which seems undesirable.

                Those who think that Math.random should give only multiples of 2^-53
                (and will in time give all such values such that 0<=X<1) can instead
                mask U[n] to 53 bits before conversion, or round the converted result to
                a multiple of 2^-53.

                --
                (c) John Stockton, near London. *@merlyn.demon. co.uk/?.?.Stockton@ph ysics.org
                Web <URL:http://www.merlyn.demo n.co.uk/- FAQish topics, acronyms, & links.
                Correct <= 4-line sig. separator as above, a line precisely "-- " (SoRFC1036)
                Do not Mail News to me. Before a reply, quote with ">" or "" (SoRFC1036)

                Comment

                • Jorge

                  #23
                  Re: How to refresh cached image ONCE

                  On Jul 22, 7:08 pm, Thomas 'PointedEars' Lahn <PointedE...@we b.de>
                  wrote:
                  >
                  I explained to you before why those alias URLs are unsuitable and
                  unnecessary in Usenet, and asked you to stop posting them.
                  >
                  Yes Thomas, you did. But I still don't agree with you. Sorry about
                  that.

                  Regards,
                  --Jorge.

                  Comment

                  • Dr J R Stockton

                    #24
                    Re: How to refresh cached image ONCE

                    In comp.lang.javas cript message <4886141A.20603 06@PointedEars. de>, Tue,
                    22 Jul 2008 19:08:42, Thomas 'PointedEars' Lahn <PointedEars@we b.de>
                    posted:
                    >Jorge wrote:
                    >"C. (http://symcbean.blogsp ot.com/)" wrote:
                    >>However, I think it may be possible to do for the client who just
                    >>uploaded the data - since, if they click the 'Refresh' button in the
                    >>browser it carries out an unconditional reload of the content. I'm
                    >>wanting to emulate this from Javascript.
                    >>
                    >See here : http://tinyurl.com/6lwmmb
                    >
                    >I explained to you before why those alias URLs are unsuitable and
                    >unnecessary in Usenet, and asked you to stop posting them.
                    >
                    >I am asking you again to post original URL(s) here instead. As a Google
                    >Groups user who heavily relies on the information in that archive, surely
                    >you can see the advantages in complying with that request.

                    Why should one be concerned with your alleged convenience in the matter
                    of compressed URLs when you persistently ignore the convenience of
                    others by not only providing but insisting upon the briefest of
                    attributions?

                    --
                    (c) John Stockton, nr London UK. ???@merlyn.demo n.co.uk Turnpike v6.05 MIME.
                    Web <URL:http://www.merlyn.demo n.co.uk/- FAQish topics, acronyms, & links.
                    Check boilerplate spelling -- error is a public sign of incompetence.
                    Never fully trust an article from a poster who gives no full real name.

                    Comment

                    • Jorge

                      #25
                      Re: How to refresh cached image ONCE

                      On 22 jul, 00:38, Dr J R Stockton <j...@merlyn.de mon.co.ukwrote:
                      >
                      I'm not entirely sure, to +/- 1 in the result, whether the algorithms
                      are ideal.  But there are clearly three cases : about 31, about 52, and
                      about 63.
                      >
                      What do you think about this :

                      do {
                      x*= 2, x-= Math.floor(x), t++;
                      } while ( x0) // shift left until empty

                      (?)

                      --Jorge.

                      Comment

                      • Dr J R Stockton

                        #26
                        Re: How to refresh cached image ONCE

                        In comp.lang.javas cript message <72ddfea4-511a-4a91-9e37-0a8be4328cd3@k3
                        6g2000pri.googl egroups.com>, Thu, 24 Jul 2008 16:56:10, Jorge
                        <jorge@jorgecha morro.composted :
                        >On 22 jul, 00:38, Dr J R Stockton <j...@merlyn.de mon.co.ukwrote:
                        >>
                        >I'm not entirely sure, to +/- 1 in the result, whether the algorithms
                        >are ideal.  But there are clearly three cases : about 31, about 52, and
                        >about 63.
                        >
                        >What do you think about this :
                        >
                        do {
                        x*= 2, x-= Math.floor(x), t++;
                        } while ( x0) // shift left until empty
                        It gives an answer one larger than the corresponding part of my code.
                        That may be better.

                        --
                        (c) John Stockton, nr London, UK. ?@merlyn.demon. co.uk Turnpike v6.05 MIME.
                        Web <URL:http://www.merlyn.demo n.co.uk/- FAQish topics, acronyms, & links.

                        Comment

                        • Dr J R Stockton

                          #27
                          Math.random is good in FF, poor in Op &amp; Sf, and wrong in IE

                          In comp.lang.javas cript message <nls87jYjQliIFw dC@invalid.uk.c o.demon.me
                          rlyn.invalid>, Fri, 25 Jul 2008 23:30:59, Dr J R Stockton
                          <jrs@merlyn.dem on.co.ukposted:
                          >In comp.lang.javas cript message <72ddfea4-511a-4a91-9e37-0a8be4328cd3@k3
                          >6g2000pri.goog legroups.com>, Thu, 24 Jul 2008 16:56:10, Jorge
                          ><jorge@jorgech amorro.composte d:
                          >>On 22 jul, 00:38, Dr J R Stockton <j...@merlyn.de mon.co.ukwrote:
                          >>>
                          >>I'm not entirely sure, to +/- 1 in the result, whether the algorithms
                          >>are ideal.  But there are clearly three cases : about 31, about 52, and
                          >>about 63.
                          >>
                          >>What do you think about this :
                          >>
                          > do {
                          > x*= 2, x-= Math.floor(x), t++;
                          > } while ( x0) // shift left until empty
                          >
                          >It gives an answer one larger than the corresponding part of my code.
                          >That may be better.
                          Or for (x = Math.random(), t = 0 ; x%1 0 ; t++) x *= 2


                          I have changed <URL:http://www.merlyn.demo n.co.uk/js-randm.htm#MR>
                          subsection "For Your Browser".

                          I see, in WinXP, Safari & Opera showing as expected for a 32-bit PRBS
                          converted to Double. Firefox has a PRBS of at least 53 bits, with my
                          results comparable with Math.random() returning only multiples of 2^-53.
                          But MSIE apparently can return an odd multiple of 2^-54, which seems
                          unsound.

                          ISO/IEC 16262 15.8.2.14 is somewhat liberal in its definition of what
                          Math.random() should give; but, as in its range the absolute resolution
                          of Number is lowest (for values of 0.5 and higher) at 2^-53, the
                          greatest uniformity is obtained by allowing return values of N * 2^-53
                          for 0 <= N < 2^53. Anything else is less than ideal.

                          Comments?

                          --
                          (c) John Stockton, near London. *@merlyn.demon. co.uk/?.?.Stockton@ph ysics.org
                          Web <URL:http://www.merlyn.demo n.co.uk/- FAQish topics, acronyms, & links.
                          Correct <= 4-line sig. separator as above, a line precisely "-- " (SoRFC1036)
                          Do not Mail News to me. Before a reply, quote with ">" or "" (SoRFC1036)

                          Comment

                          • Jorge

                            #28
                            Re: Math.random is good in FF, poor in Op &amp; Sf, and wrong in IE

                            On Jul 27, 2:59 pm, Dr J R Stockton <j...@merlyn.de mon.co.ukwrote:
                            In comp.lang.javas cript message <nls87jYjQliIF. ..@invalid.uk.c o.demon.me
                            rlyn.invalid>, Fri, 25 Jul 2008 23:30:59, Dr J R Stockton
                            <j...@merlyn.de mon.co.ukposted :
                            >
                            >
                            >
                            >
                            >
                            In comp.lang.javas cript message <72ddfea4-511a-4a91-9e37-0a8be4328cd3@k3
                            6g2000pri.googl egroups.com>, Thu, 24 Jul 2008 16:56:10, Jorge
                            <jo...@jorgecha morro.composted :
                            >On 22 jul, 00:38, Dr J R Stockton <j...@merlyn.de mon.co.ukwrote:
                            >
                            >I'm not entirely sure, to +/- 1 in the result, whether the algorithms
                            >are ideal.  But there are clearly three cases : about 31, about 52,and
                            >about 63.
                            >
                            >What do you think about this :
                            >
                                   do {
                                     x*= 2, x-= Math.floor(x), t++;
                                   } while ( x0) // shift left until empty
                            >
                            It gives an answer one larger than the corresponding part of my code.
                            That may be better.
                            >
                            Or    for (x = Math.random(), t = 0 ; x%1 0 ; t++) x *= 2
                            >
                            I have changed <URL:http://www.merlyn.demo n.co.uk/js-randm.htm#MR>
                            subsection "For Your Browser".
                            >
                            I see, in WinXP, Safari & Opera showing as expected for a 32-bit PRBS
                            converted to Double.  Firefox has a PRBS of at least 53 bits, with my
                            results comparable with Math.random() returning only multiples of 2^-53.
                            But MSIE apparently can return an odd multiple of 2^-54, which seems
                            unsound.
                            >
                            ISO/IEC 16262 15.8.2.14 is somewhat liberal in its definition of what
                            Math.random() should give; but, as in its range the absolute resolution
                            of Number is lowest (for values of 0.5 and higher) at 2^-53, the
                            greatest uniformity is obtained by allowing return values of N * 2^-53
                            for 0 <= N < 2^53.  Anything else is less than ideal.
                            >
                            Comments?
                            >
                            On a Mac: resolA, resolB, resolC :

                            Safari 3.1.2: 31,31,31
                            FF 2.0.0.16 : 53,53,53
                            FF 3.0.1 : 53,53,53
                            Opera 9.5.1: 32, 32, 32
                            IE 5.2.3: 54,53,54
                            iCab 3.0.5: 64,53,57

                            --Jorge.

                            Comment

                            • Jorge

                              #29
                              Re: Math.random is best in FF, good in Op &amp; Sf, and wrong in IE

                              On Jul 27, 2:59 pm, Dr J R Stockton <j...@merlyn.de mon.co.ukwrote:
                              In comp.lang.javas cript message <nls87jYjQliIF. ..@invalid.uk.c o.demon.me
                              rlyn.invalid>, Fri, 25 Jul 2008 23:30:59, Dr J R Stockton
                              <j...@merlyn.de mon.co.ukposted :
                              >
                              >
                              >
                              >
                              >
                              In comp.lang.javas cript message <72ddfea4-511a-4a91-9e37-0a8be4328cd3@k3
                              6g2000pri.googl egroups.com>, Thu, 24 Jul 2008 16:56:10, Jorge
                              <jo...@jorgecha morro.composted :
                              >On 22 jul, 00:38, Dr J R Stockton <j...@merlyn.de mon.co.ukwrote:
                              >
                              >I'm not entirely sure, to +/- 1 in the result, whether the algorithms
                              >are ideal.  But there are clearly three cases : about 31, about 52,and
                              >about 63.
                              >
                              >What do you think about this :
                              >
                                     do {
                                       x*= 2, x-= Math.floor(x), t++;
                                     } while ( x0) // shift left until empty
                              >
                              It gives an answer one larger than the corresponding part of my code.
                              That may be better.
                              >
                              Or    for (x = Math.random(), t = 0 ; x%1 0 ; t++) x *= 2
                              >
                              I have changed <URL:http://www.merlyn.demo n.co.uk/js-randm.htm#MR>
                              subsection "For Your Browser".
                              >
                              I see, in WinXP, Safari & Opera showing as expected for a 32-bit PRBS
                              converted to Double.  Firefox has a PRBS of at least 53 bits, with my
                              results comparable with Math.random() returning only multiples of 2^-53.
                              But MSIE apparently can return an odd multiple of 2^-54, which seems
                              unsound.
                              >
                              ISO/IEC 16262 15.8.2.14 is somewhat liberal in its definition of what
                              Math.random() should give; but, as in its range the absolute resolution
                              of Number is lowest (for values of 0.5 and higher) at 2^-53, the
                              greatest uniformity is obtained by allowing return values of N * 2^-53
                              for 0 <= N < 2^53.  Anything else is less than ideal.
                              >
                              Comments?
                              >
                              On a Mac: resolA, resolB, resolC :

                              Safari 3.1.2: 31,31,31
                              FF 2.0.0.16 : 53,53,53
                              FF 3.0.1 : 53,53,53
                              Opera 9.5.1: 32, 32, 32
                              IE 5.2.3: 54,53,54
                              iCab 3.0.5: 64,53,57

                              --Jorge.

                              Comment

                              • Dr J R Stockton

                                #30
                                Re: Math.random is best in FF, good in Op &amp; Sf, and wrong in IE

                                On Jul 27, 7:42 pm, Jorge <jo...@jorgecha morro.comwrote:
                                On Jul 27, 2:59 pm, Dr J R Stockton <j...@merlyn.de mon.co.ukwrote:
                                I have changed <URL:http://www.merlyn.demo n.co.uk/js-randm.htm#MR>
                                subsection "For Your Browser".
                                >
                                I see, in WinXP, Safari & Opera showing as expected for a 32-bit PRBS
                                converted to Double.  Firefox has a PRBS of at least 53 bits, with my
                                results comparable with Math.random() returning only multiples of 2^-53..
                                But MSIE apparently can return an odd multiple of 2^-54, which seems
                                unsound.
                                Comments?
                                >
                                On a Mac: resolA, resolB, resolC :
                                >
                                Safari 3.1.2: 31,31,31
                                FF 2.0.0.16 : 53,53,53
                                FF 3.0.1 : 53,53,53
                                Opera 9.5.1: 32, 32, 32
                                IE 5.2.3: 54,53,54
                                iCab 3.0.5: 64,53,57

                                Thanks; I've updated the page. It may be that with various different
                                range parameters for ResolC a greater understanding of what iCab is
                                doing might be obtained. The author of iCab can be found via <http://
                                www.icab.de/>.

                                --
                                (c) John Stockton, near London, UK. Posting with Google.
                                Mail: J.R.""""""""@ph ysics.org or (better) via Home Page at
                                Web: <URL:http://www.merlyn.demo n.co.uk/>
                                FAQish topics, acronyms, links, etc.; Date, Delphi, JavaScript, ...

                                Comment

                                Working...