sneaky squid
sneaky squid

Reputation: 156

Data structure to represent statistical table lookup data

I'm performing some statistical calculations where I need to lookup values from various tables dynamically.

I've tried representing the following data as JSON, and querying the relevant value: enter image description here

using JsonDocument doc = JsonDocument.Parse(json);
JsonElement w_test_table = doc.RootElement;

w_test_table.GetProperty(factor).GetProperty(sampleCount.ToString()).GetDouble();

However this feels like I'm going down a bad path.

I have multiple tables I need to lookup for each calculation, so I'm starting to think there's a better way to do this that I'm unaware of.

My concern with storing this in the DB is that I'd have multiple round trips querying the DB to resolve the value. The calculations I'm performing are done on a collection of sample sets - multiple sample sets I'm running the stats for, hence multiple times I need to resolve the values from various lookup tables, the input values will differ each time.

Any ideas on how I can represent these kinds of lookup tables in C# would be appreciated.

Upvotes: 1

Views: 39

Answers (1)

Mihail
Mihail

Reputation: 823

You could use a Data Table or a Multi-Dimensional array.

However since you may have a specific use case, you may want to have a custom class that holds the data inside using one of the above structures and have methods that abstract your specific logic.

Upvotes: 1

Related Questions