|XP is just a number|
creating and managing many hashesby Gtforce (Sexton)
|on Feb 18, 2018 at 07:18 UTC||Need Help??|
Gtforce has asked for the wisdom of the Perl Monks concerning the following question:
My data is as follows:
where apple and orange are my products, and I have over 2,000 distinct products. The values 201,202, etc are the prices of those products on the respective dates represented in the first column (and the quantities aka inventories are in the last column). My data series is for the past 3 years for each of these products.
I need to pass the data series (i.e., price and inventory) for one product at a time to a subroutine that calculates the mean, std.dev, etc.
I also need to pass the data series for a combination of two products at a time (a pair) to a subroutine that calculates the correlation between the two data series.
I have currently done this using arrays over the 2 million pairs that arise from 2,000 products and it ran for 4 days before my patience ran out and I terminated the process. I've only just started reading up on hashes and I think I can speed up things if I get the data series for one product into one hash, and the data series for another product into another hash (likewise for 2,000 products or hashes).
The reading I've done so far warns me against using variables for hashnames. Any advice you can offer would be greatly appreciated, thanks.
Update: using the advice on this thread, I was able to get to processing those stats for the 2 million odd pairs in 4hrs and 10 mins, and incidentally, learnt how to use hashes. Thank you