# How to find the regions corresponding to a given data set?

I have a data set corresponding to some problem. The data set is just a numerical sampling of $$(x,y,z)$$ where a particular formula is valid( this thing is analytically intractable that's why I resorted to numerical sampling method). This data set in belongs to a specific volume in the 3-D space. My question is two-fold.

1. Let's say I have some point $$(x1,x2,x3)$$; how do I check whether it lies inside the above-said volume or not? Directly checking whether the point lies in the list or not is pointless as the data might have a point $$(x1+\epsilon,x2,x3)$$ and $$(x1-\epsilon,x2,x3)$$ but not $$(x1,x2,x3)$$ exactly.

2. Is there a way to find the inequality that can approximately define the above-said volume?

As an easy example in 1-D, let's say the data contains (0,.1,.2,...,1), which means the formula is valid from 0 to 1. Now question 1 is asking if .23 lies in the region or not. And the second question for this simple case would be whether I can define the region or not in this case we can see that it can be defined as $$0.

Edit: Consider a 2-d case. Let say I generate the following list of data

list = Flatten[Table[{x, y}, {x, 0, 1, .1}, {y, 0, 1, .1}], 1]

{{0., 0.}, {0., 0.1}, {0., 0.2}, {0., 0.3}, {0., 0.4}, {0., 0.5}, {0.,
0.6}, {0., 0.7}, {0., 0.8}, {0., 0.9}, {0., 1.}, {0.1, 0.}, {0.1,
0.1}, {0.1, 0.2}, {0.1, 0.3}, {0.1, 0.4}, {0.1, 0.5}, {0.1,
0.6}, {0.1, 0.7}, {0.1, 0.8}, {0.1, 0.9}, {0.1, 1.}, {0.2,
0.}, {0.2, 0.1}, {0.2, 0.2}, {0.2, 0.3}, {0.2, 0.4}, {0.2,
0.5}, {0.2, 0.6}, {0.2, 0.7}, {0.2, 0.8}, {0.2, 0.9}, {0.2,
1.}, {0.3, 0.}, {0.3, 0.1}, {0.3, 0.2}, {0.3, 0.3}, {0.3,
0.4}, {0.3, 0.5}, {0.3, 0.6}, {0.3, 0.7}, {0.3, 0.8}, {0.3,
0.9}, {0.3, 1.}, {0.4, 0.}, {0.4, 0.1}, {0.4, 0.2}, {0.4,
0.3}, {0.4, 0.4}, {0.4, 0.5}, {0.4, 0.6}, {0.4, 0.7}, {0.4,
0.8}, {0.4, 0.9}, {0.4, 1.}, {0.5, 0.}, {0.5, 0.1}, {0.5,
0.2}, {0.5, 0.3}, {0.5, 0.4}, {0.5, 0.5}, {0.5, 0.6}, {0.5,
0.7}, {0.5, 0.8}, {0.5, 0.9}, {0.5, 1.}, {0.6, 0.}, {0.6,
0.1}, {0.6, 0.2}, {0.6, 0.3}, {0.6, 0.4}, {0.6, 0.5}, {0.6,
0.6}, {0.6, 0.7}, {0.6, 0.8}, {0.6, 0.9}, {0.6, 1.}, {0.7,
0.}, {0.7, 0.1}, {0.7, 0.2}, {0.7, 0.3}, {0.7, 0.4}, {0.7,
0.5}, {0.7, 0.6}, {0.7, 0.7}, {0.7, 0.8}, {0.7, 0.9}, {0.7,
1.}, {0.8, 0.}, {0.8, 0.1}, {0.8, 0.2}, {0.8, 0.3}, {0.8,
0.4}, {0.8, 0.5}, {0.8, 0.6}, {0.8, 0.7}, {0.8, 0.8}, {0.8,
0.9}, {0.8, 1.}, {0.9, 0.}, {0.9, 0.1}, {0.9, 0.2}, {0.9,
0.3}, {0.9, 0.4}, {0.9, 0.5}, {0.9, 0.6}, {0.9, 0.7}, {0.9,
0.8}, {0.9, 0.9}, {0.9, 1.}, {1., 0.}, {1., 0.1}, {1., 0.2}, {1.,
0.3}, {1., 0.4}, {1., 0.5}, {1., 0.6}, {1., 0.7}, {1., 0.8}, {1.,
0.9}, {1., 1.}}



If we see the above data, we see that it lies inside a square of unit length. How do I check now that the point (.92,.95) would lie in the above-defined region?

• Please post some data and Mathematica code. Commented Oct 5, 2022 at 7:37

Let's construct an example. Two regions (a rectangle and a disk) are defined and verified as being regions.

r1 = Rectangle[{0, 0}, {40, 40}];
r2 = Disk[{50, 50}, 20];
RegionQ /@ {r1, r2}


Thirty random points are generated in each of the regions and the lists are joined together.

alist = Catenate[{
RandomPoint[r1, 30]
, RandomPoint[r2, 30]
}];


A few points are defined for checking the setup.

checkpts = {{20, 20}, {60, 10}, {60, 60}};


A resource function is used to generate a mesh while deleting triangles that are larger than the sensitivity specified.

m1 = ResourceFunction["NonConvexHullMesh"][alist, 22]


RegionMember[m1, #] & /@ checkpts


{True, False, True}

g1 = Graphics[{
FaceForm[{Opacity[0.4], Gray}]
, r1, r2
, Point@alist
, Opacity[1]
, Red, AbsolutePointSize[8]
, Point@checkpts
}]


Show[m1, g1]


It comes down to the definition of the region from your points using the right tools and only you can decide what works best for you. For the 3D-case, you can explore GradientFittedMesh in v13, but I am running v12.2.0.

Regarding the second question, I don't know if a solution exists for generating an inequality from points, but the world of Mathematics is vast.

Original

There are many functions to work with regions. For your 1-D example:

alist = Range[0, 1, 0.1];
iv1 = Interval[{Min@alist, Max@alist}] // Chop;
RegionQ[iv1]


True

IntervalMemberQ[iv1, 0.23]


True

EDIT-I

reg = ImplicitRegion[0 < x < 1, x]
RegionQ[reg]
RegionMember[reg, {0.23}]


The Region functions can work with more dimensions. You can specify named regions, polygons etc and do operations on those regions. But in your question, you have said that you don't have a formula for the analytically intractable region. Until you load a more concrete dataset, it will hard to offer a more concrete answer. For now, please explore Region* functions a bit more.

You can modify/alter the question with an example that is more useful to you. I will either modify this answer, if I can participate or remove this one.

• Thank you so much. NonConvexHullMesh is exactly the thing I was looking for. It worked as I needed. Commented Oct 5, 2022 at 8:41
– Syed
Commented Oct 5, 2022 at 10:28
• Also explore the ConcaveHullMesh function that was introduced in v13 here
– Syed
Commented Oct 5, 2022 at 12:50
• Sure thank you for your help. It had been great help. In the meantime I am also try to see if I can maybe find some inequalities so as to get the region. Commented Oct 5, 2022 at 16:23

Edit

reg1=ReconstructionMesh[list];
reg2=ConvexHullRegion[list];
RegionMember[reg1]@{.92,.95}
RegionMember[reg2]@{.92,.95}
RegionConvert[reg1, "Implicit"]
RegionConvert[reg2, "Implicit"]


True

Original

Maybe

Clear[pts,reg1];
pts = RandomReal[{-5, 5}, {20, 3}];
reg1=ConvexHullMesh[pts]
RegionConvert[reg1, "Implicit"]

Clear[pts,reg2];
pts = RandomReal[{-5, 5}, {20, 3}];
reg2=ReconstructionMesh[pts]