I like it as a sample. I don't understand the bigint case - at the moment you call BitConverter.ToDouble, so it seems that bigIntNumber is of type Double. Also you don't use bigIntRange. If the plan is to allow for arbitrarily large numbers, then you will need a way to convert bytes into bigint, I guess by multiplying up the words.

James has been doing a bunch of optimizations on the bigint library - now vastly improved. That should make it into the next release. Perhaps he could be encouraged to write an article on the implementation?

Don

By on 3/31/2006 2:35 PM ()

Yup, you are correct. That bigint case is not completed and I marked it with a "TODO". The algorithm is essentially:

  1. Determine the range, i.e. subtract the upper from the lower bound.
  2. Get the number of bits necessary to encode that range as a value.
  3. Call the crypto random bits routine to get that number of random bits.
  4. Using the actual range from the bits and the actual range as calculated in step one, determine a bigrational ratio that will be used to scale the binary representation. NB: Nearly any other usage of the resulting bits will introduce bias. (try mod or other operations to see how the distribution is affected).
  5. Convert the random bits to bigint (through multiplication or otherwise; there has to be a shortcut here, Karatsuba or otherwise; or maybe James has a few ideas).
  6. Multiply the result of step five with the results of step four.

My question is, is this appropriate? Is it overkill? Personally, I think these are on point, but I'm anal retentive and think that principles in Numerical Analysis in this setting are needed. Please note that if you work in crypto or randomized algorithm implementation, step four is critical.

Also, I was trying to determine if this was a sample, or the beginnings of a numerical methods library. Anyone doing work with similar depth (or exceeding what I practice) will find use for these or improve them.

OK, just by discussing this, I've convinced myself that this last one should be done. I'll finish that case in a day or two and post the new sample. I'll also work on the text for a surrounding article.

By on 4/2/2006 8:38 PM ()

Speaking of random numbers have you seen this? Truly random numbers:
[link:www.idquantique.com]

As far as Bignum stuff goes I think it's interesting but I can't make a valid comment on it because I have no active projects that currently use Bignum libraries right now. I think personally your efforst are better spent on basic tutorials because most of the traffic that comes to the site will be people looking to learn the language not people who already know it and want it to accomplish X complex functionality. As your site traffic learns more about the language you will get users posting this kind of stuff kind of like a CodeProject for F#. In the beggining though I think your interests are best served with simple examples of how to use F# and how to write programs in it. Basic console apps, basic Windows, how to make the thing go beep basically. Once you have that core foundation down you can start in with the medium hard tutorials, then put up the really hard stuff. Because if the person doesn't deal with crypto to begin with they won't understand what you are trying to do let alone what the F# code does.

By on 3/29/2006 11:01 AM ()

Thanks for that link. I had heard of those devices, but hadn't had a chance to see them in action.

Regarding the arbitrary precision stuff, I think it is a reason that many people will "come to F#", i.e. most other implementations of arbitrary precision math are open libraries or commercial libraries, many of which are costly to extend or integrate.

I mentioned periodicity in random number generation, and that and other attributes are important. For example, the Mersenne Twister that I mentioned is a linear random number generator and is therefore not suitable for cryptography, but may be suitable for some randomized algorithms (in my opinion, it is not).

I'll take the spirit of Don's comment and just finish the bigint case. That way, someone else can run the random cases as they see fit.

By on 4/2/2006 8:38 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper