Forum

General discussion on using the Kognitio Analytical Platform.
Contributor
Offline
User avatar
Posts: 27
Joined: Thu Jun 26, 2014 3:23 pm

Generating a random number

by William » Thu Oct 22, 2015 3:22 pm

Hi,

I think I'm right in saying Kognitio doesn't have a 'random' number function.
Can you suggest a nice formula for creating a pseudo-random number based on a seed value, in this case a customer key?

Thanks in advance,

Will
Reply with quote Top
Contributor
Offline
User avatar
Posts: 386
Joined: Thu May 23, 2013 4:48 pm

Re: Generating a random number

by markc » Thu Oct 22, 2015 3:29 pm

Hi,

The way I normally handle this is using the hash_value function to get something pseudo-random.

A typical requirement is to e.g. sample 1% of customers - so in this case you can do "... where hash_value(customer_id) % 100 = 17", for example.

The issue with having an in-built random number function is that accesses in Kognitio have to be repeatable because of the streaming mechanism that may require an access to be rerun, and which relies on that access giving exactly the same results this time as last time. So any random number function would need to be repeatable in that way.
Reply with quote Top
Contributor
Offline
User avatar
Posts: 27
Joined: Thu Jun 26, 2014 3:23 pm

Re: Generating a random number

by William » Mon Oct 26, 2015 10:18 am

Hi Markc,

This is really useful.

Thanks,

Will
Reply with quote Top

Who is online

Users browsing this forum: No registered users and 1 guest

cron