Skip to content

Commit e088561

Browse files
Capacity tests
1 parent cb7744f commit e088561

File tree

2 files changed

+343
-0
lines changed

2 files changed

+343
-0
lines changed
Lines changed: 343 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,343 @@
1+
(*CacheID: 234*)
2+
(* Internal cache information:
3+
NotebookFileLineBreakTest
4+
NotebookFileLineBreakTest
5+
NotebookDataPosition[ 0, 0]
6+
NotebookDataLength[ 11484, 342]
7+
NotebookOptionsPosition[ 7934, 264]
8+
NotebookOutlinePosition[ 8457, 284]
9+
CellTagsIndexPosition[ 8414, 281]
10+
WindowFrame->Normal*)
11+
12+
(* Beginning of Notebook Content *)
13+
Notebook[{
14+
Cell["Triadic Memory Capacity", "Subsection",
15+
CellGroupingRules->{
16+
"GroupTogetherGrouping",
17+
10000.},ExpressionUUID->"f85a3d7f-356b-4c04-8a07-4f926ca5375c"],
18+
19+
Cell["\<\
20+
Store 1 million random triples in a triadic memory and test retrieval accuracy.
21+
22+
The configuration used in this test is n=1000 and p=10.
23+
\
24+
\>", "CodeText",ExpressionUUID->"8e8d38f4-526f-414c-a16f-2ccf6f3d3c73"],
25+
26+
Cell[CellGroupData[{
27+
28+
Cell["Initialization", "Subsubsection",ExpressionUUID->"e1b72c8d-e4de-4146-a485-218c9ffef3ce"],
29+
30+
Cell[BoxData[
31+
RowBox[{"Get", "[", " ",
32+
RowBox[{
33+
"$UserBaseDirectory", " ", "<>", " ",
34+
"\"\</TriadicMemory/triadicmemoryC.m\>\""}], "]"}]], "Input",
35+
CellLabel->"In[1]:=",ExpressionUUID->"fb15d5f5-eed3-4124-94d3-231d7af8e604"],
36+
37+
Cell[BoxData[
38+
RowBox[{
39+
RowBox[{"TriadicMemory", "[",
40+
RowBox[{"M", ",",
41+
RowBox[{"{",
42+
RowBox[{"1000", ",", "10"}], "}"}]}], "]"}], ";"}]], "Input",
43+
CellGroupingRules->{"GroupTogetherGrouping", 10001.},
44+
CellLabel->"In[2]:=",ExpressionUUID->"87f24557-45f3-412f-9d2a-aea44c063666"]
45+
}, Open ]],
46+
47+
Cell[CellGroupData[{
48+
49+
Cell["Generate test data: k random triples {x,y,z}", "Subsubsection",ExpressionUUID->"0f0d62e0-af44-461f-b78b-0da6de1ab37c"],
50+
51+
Cell[BoxData[
52+
RowBox[{
53+
RowBox[{"k", " ", "=", " ", "1000000"}], ";"}]], "Input",
54+
CellLabel->"In[3]:=",ExpressionUUID->"dc4998bd-74ba-4c7d-9e2b-f94e647b33bf"],
55+
56+
Cell[BoxData[
57+
RowBox[{
58+
RowBox[{"data", " ", "=", " ",
59+
RowBox[{"Table", "[", " ",
60+
RowBox[{
61+
RowBox[{"{",
62+
RowBox[{
63+
RowBox[{"M", "[", "]"}], ",",
64+
RowBox[{"M", "[", "]"}], ",",
65+
RowBox[{"M", "[", "]"}]}], "}"}], ",", " ", "k"}], "]"}]}],
66+
";"}]], "Input",
67+
CellLabel->"In[4]:=",ExpressionUUID->"db0eb835-d34e-4765-87cb-c2a7281ce297"]
68+
}, Open ]],
69+
70+
Cell[CellGroupData[{
71+
72+
Cell["Store test data in memory", "Subsubsection",ExpressionUUID->"dbc5b0e8-d45c-42e2-8e7b-aae8f401625d"],
73+
74+
Cell[CellGroupData[{
75+
76+
Cell[BoxData[
77+
RowBox[{
78+
RowBox[{
79+
RowBox[{"M", " ", "@@@", " ", "data"}], ";"}], " ", "//", " ",
80+
"AbsoluteTiming"}]], "Input",
81+
CellLabel->"In[5]:=",ExpressionUUID->"1114b537-1526-4baf-8245-4790dd01cd3a"],
82+
83+
Cell[BoxData[
84+
RowBox[{"{",
85+
RowBox[{"127.854022`", ",", "Null"}], "}"}]], "Output",
86+
CellLabel->"Out[5]=",ExpressionUUID->"fac31edd-6aa5-4abf-8adc-39e4430356fe"]
87+
}, Open ]]
88+
}, Open ]],
89+
90+
Cell[CellGroupData[{
91+
92+
Cell["Recall all z and calculate the retrieval accuracy", "Subsubsection",ExpressionUUID->"5b4dc598-d4b4-4283-ac61-e1f6d6c1d388"],
93+
94+
Cell[CellGroupData[{
95+
96+
Cell[BoxData[
97+
RowBox[{
98+
RowBox[{
99+
RowBox[{"out", " ", "=", " ",
100+
RowBox[{
101+
RowBox[{
102+
RowBox[{"M", "[",
103+
RowBox[{
104+
RowBox[{"#", "[",
105+
RowBox[{"[", "1", "]"}], "]"}], ",", " ",
106+
RowBox[{"#", "[",
107+
RowBox[{"[", "2", "]"}], "]"}], ",", " ",
108+
StyleBox["_",
109+
FontColor->GrayLevel[0]]}], "]"}], "&"}], " ", "/@", " ",
110+
"data"}]}], ";"}], " ", "//", " ", "AbsoluteTiming"}]], "Input",
111+
CellLabel->"In[6]:=",ExpressionUUID->"e87bba5b-1e1d-4e09-add8-fd8fdf23e902"],
112+
113+
Cell[BoxData[
114+
RowBox[{"{",
115+
RowBox[{"408.573932`", ",", "Null"}], "}"}]], "Output",
116+
CellLabel->"Out[6]=",ExpressionUUID->"149a1b60-9c53-4a44-a945-f2f5dfbfc603"]
117+
}, Open ]],
118+
119+
Cell[CellGroupData[{
120+
121+
Cell[BoxData[
122+
RowBox[{
123+
RowBox[{
124+
RowBox[{"Table", "[", " ",
125+
RowBox[{
126+
RowBox[{"HammingDistance", "[",
127+
RowBox[{
128+
RowBox[{"out", "[",
129+
RowBox[{"[", "i", "]"}], "]"}], ",", " ",
130+
RowBox[{"data", "[",
131+
RowBox[{"[",
132+
RowBox[{"i", ",", "3"}], "]"}], "]"}]}], "]"}], ",", " ",
133+
RowBox[{"{",
134+
RowBox[{"i", ",", " ", "1", ",", " ",
135+
RowBox[{"Length", "[", "data", "]"}]}], "}"}]}], "]"}], " ", "//", " ",
136+
"Tally"}], " ", "//", " ", "Sort"}]], "Input",
137+
CellLabel->"In[7]:=",ExpressionUUID->"89204da9-2e6d-4f80-bdd3-29f771c5b5fa"],
138+
139+
Cell[BoxData[
140+
RowBox[{"{",
141+
RowBox[{"{",
142+
RowBox[{"0", ",", "1000000"}], "}"}], "}"}]], "Output",
143+
CellLabel->"Out[7]=",ExpressionUUID->"991bafb7-d02c-4068-92a4-6351b0906bde"]
144+
}, Open ]]
145+
}, Open ]],
146+
147+
Cell[CellGroupData[{
148+
149+
Cell["Recall all y and calculate the retrieval accuracy", "Subsubsection",ExpressionUUID->"16f79d81-0a75-40a5-92a6-f1ae81c617c5"],
150+
151+
Cell[CellGroupData[{
152+
153+
Cell[BoxData[
154+
RowBox[{
155+
RowBox[{
156+
RowBox[{"out", " ", "=", " ",
157+
RowBox[{
158+
RowBox[{
159+
RowBox[{"M", "[",
160+
RowBox[{
161+
RowBox[{"#", "[",
162+
RowBox[{"[", "1", "]"}], "]"}], ",",
163+
StyleBox["_",
164+
FontColor->GrayLevel[0]], ",", " ",
165+
RowBox[{"#", "[",
166+
RowBox[{"[", "3", "]"}], "]"}]}], "]"}], "&"}], " ", "/@", " ",
167+
"data"}]}], ";"}], " ", "//", " ", "AbsoluteTiming"}]], "Input",
168+
CellLabel->"In[8]:=",ExpressionUUID->"aa9787a5-a9e8-4c91-a0ce-4b41515f8ae5"],
169+
170+
Cell[BoxData[
171+
RowBox[{"{",
172+
RowBox[{"1024.14402`", ",", "Null"}], "}"}]], "Output",
173+
CellLabel->"Out[8]=",ExpressionUUID->"303ce45e-606b-4890-ba26-399cd5ac40eb"]
174+
}, Open ]],
175+
176+
Cell[CellGroupData[{
177+
178+
Cell[BoxData[
179+
RowBox[{
180+
RowBox[{"Table", "[", " ",
181+
RowBox[{
182+
RowBox[{"HammingDistance", "[",
183+
RowBox[{
184+
RowBox[{"out", "[",
185+
RowBox[{"[", "i", "]"}], "]"}], ",", " ",
186+
RowBox[{"data", "[",
187+
RowBox[{"[",
188+
RowBox[{"i", ",", "2"}], "]"}], "]"}]}], "]"}], ",", " ",
189+
RowBox[{"{",
190+
RowBox[{"i", ",", " ", "1", ",", " ",
191+
RowBox[{"Length", "[", "data", "]"}]}], "}"}]}], "]"}], " ", "//", " ",
192+
"Tally"}]], "Input",
193+
CellLabel->"In[9]:=",ExpressionUUID->"31477670-68ba-454d-9a10-4a4e3aeb9039"],
194+
195+
Cell[BoxData[
196+
RowBox[{"{",
197+
RowBox[{
198+
RowBox[{"{",
199+
RowBox[{"0", ",", "999997"}], "}"}], ",",
200+
RowBox[{"{",
201+
RowBox[{"2", ",", "3"}], "}"}]}], "}"}]], "Output",
202+
CellLabel->"Out[9]=",ExpressionUUID->"3c5466cf-df1a-4061-9402-a1236477d8a7"]
203+
}, Open ]]
204+
}, Open ]],
205+
206+
Cell[CellGroupData[{
207+
208+
Cell["Recall all x and calculate the retrieval accuracy", "Subsubsection",ExpressionUUID->"f501fbf3-dd43-45f5-91da-f4625d4977db"],
209+
210+
Cell[CellGroupData[{
211+
212+
Cell[BoxData[
213+
RowBox[{
214+
RowBox[{
215+
RowBox[{"out", " ", "=", " ",
216+
RowBox[{
217+
RowBox[{
218+
RowBox[{"M", "[",
219+
RowBox[{
220+
StyleBox["_",
221+
FontColor->GrayLevel[0]], ",",
222+
RowBox[{"#", "[",
223+
RowBox[{"[", "2", "]"}], "]"}], ",",
224+
RowBox[{"#", "[",
225+
RowBox[{"[", "3", "]"}], "]"}]}], "]"}], "&"}], " ", "/@", " ",
226+
"data"}]}], ";"}], " ", "//", " ", "AbsoluteTiming"}]], "Input",
227+
CellLabel->"In[10]:=",ExpressionUUID->"1b33b278-c8a2-4f16-804e-8b749cfa1adb"],
228+
229+
Cell[BoxData[
230+
RowBox[{"{",
231+
RowBox[{"1234.812001`", ",", "Null"}], "}"}]], "Output",
232+
CellLabel->"Out[10]=",ExpressionUUID->"1a697d21-afc4-4fdc-84dd-755797fc03e8"]
233+
}, Open ]],
234+
235+
Cell[CellGroupData[{
236+
237+
Cell[BoxData[
238+
RowBox[{
239+
RowBox[{"Table", "[", " ",
240+
RowBox[{
241+
RowBox[{"HammingDistance", "[",
242+
RowBox[{
243+
RowBox[{"out", "[",
244+
RowBox[{"[", "i", "]"}], "]"}], ",", " ",
245+
RowBox[{"data", "[",
246+
RowBox[{"[",
247+
RowBox[{"i", ",", "1"}], "]"}], "]"}]}], "]"}], ",", " ",
248+
RowBox[{"{",
249+
RowBox[{"i", ",", " ", "1", ",", " ",
250+
RowBox[{"Length", "[", "data", "]"}]}], "}"}]}], "]"}], " ", "//", " ",
251+
"Tally"}]], "Input",
252+
CellLabel->"In[11]:=",ExpressionUUID->"f702b32f-fca8-42f2-bbc9-515beea2b3df"],
253+
254+
Cell[BoxData[
255+
RowBox[{"{",
256+
RowBox[{
257+
RowBox[{"{",
258+
RowBox[{"0", ",", "999999"}], "}"}], ",",
259+
RowBox[{"{",
260+
RowBox[{"2", ",", "1"}], "}"}]}], "}"}]], "Output",
261+
CellLabel->"Out[11]=",ExpressionUUID->"6173f5fb-9a3a-463b-934d-e78ba3b4e5e0"]
262+
}, Open ]]
263+
}, Open ]]
264+
},
265+
WindowSize->{1087, 1030},
266+
WindowMargins->{{211, Automatic}, {-126, Automatic}},
267+
PrintingCopies->1,
268+
PrintingPageRange->{1, Automatic},
269+
TaggingRules->{"TryRealOnly" -> False},
270+
Magnification:>1.25 Inherited,
271+
FrontEndVersion->"12.1 for Mac OS X x86 (64-bit) (June 19, 2020)",
272+
StyleDefinitions->"Default.nb",
273+
ExpressionUUID->"4df8e693-47dc-4049-9c05-c2f0330fe39a"
274+
]
275+
(* End of Notebook Content *)
276+
277+
(* Internal cache information *)
278+
(*CellTagsOutline
279+
CellTagsIndex->{}
280+
*)
281+
(*CellTagsIndex
282+
CellTagsIndex->{}
283+
*)
284+
(*NotebookFileOutline
285+
Notebook[{
286+
Cell[400, 13, 162, 3, 67, "Subsection",ExpressionUUID->"f85a3d7f-356b-4c04-8a07-4f926ca5375c",
287+
CellGroupingRules->{"GroupTogetherGrouping", 10000.}],
288+
Cell[565, 18, 220, 5, 127, "CodeText",ExpressionUUID->"8e8d38f4-526f-414c-a16f-2ccf6f3d3c73"],
289+
Cell[CellGroupData[{
290+
Cell[810, 27, 94, 0, 56, "Subsubsection",ExpressionUUID->"e1b72c8d-e4de-4146-a485-218c9ffef3ce"],
291+
Cell[907, 29, 236, 5, 37, "Input",ExpressionUUID->"fb15d5f5-eed3-4124-94d3-231d7af8e604"],
292+
Cell[1146, 36, 296, 7, 37, "Input",ExpressionUUID->"87f24557-45f3-412f-9d2a-aea44c063666",
293+
CellGroupingRules->{"GroupTogetherGrouping", 10001.}]
294+
}, Open ]],
295+
Cell[CellGroupData[{
296+
Cell[1479, 48, 124, 0, 56, "Subsubsection",ExpressionUUID->"0f0d62e0-af44-461f-b78b-0da6de1ab37c"],
297+
Cell[1606, 50, 161, 3, 37, "Input",ExpressionUUID->"dc4998bd-74ba-4c7d-9e2b-f94e647b33bf"],
298+
Cell[1770, 55, 377, 11, 37, "Input",ExpressionUUID->"db0eb835-d34e-4765-87cb-c2a7281ce297"]
299+
}, Open ]],
300+
Cell[CellGroupData[{
301+
Cell[2184, 71, 105, 0, 56, "Subsubsection",ExpressionUUID->"dbc5b0e8-d45c-42e2-8e7b-aae8f401625d"],
302+
Cell[CellGroupData[{
303+
Cell[2314, 75, 211, 5, 37, "Input",ExpressionUUID->"1114b537-1526-4baf-8245-4790dd01cd3a"],
304+
Cell[2528, 82, 164, 3, 42, "Output",ExpressionUUID->"fac31edd-6aa5-4abf-8adc-39e4430356fe"]
305+
}, Open ]]
306+
}, Open ]],
307+
Cell[CellGroupData[{
308+
Cell[2741, 91, 129, 0, 56, "Subsubsection",ExpressionUUID->"5b4dc598-d4b4-4283-ac61-e1f6d6c1d388"],
309+
Cell[CellGroupData[{
310+
Cell[2895, 95, 534, 15, 37, "Input",ExpressionUUID->"e87bba5b-1e1d-4e09-add8-fd8fdf23e902"],
311+
Cell[3432, 112, 164, 3, 42, "Output",ExpressionUUID->"149a1b60-9c53-4a44-a945-f2f5dfbfc603"]
312+
}, Open ]],
313+
Cell[CellGroupData[{
314+
Cell[3633, 120, 601, 16, 64, "Input",ExpressionUUID->"89204da9-2e6d-4f80-bdd3-29f771c5b5fa"],
315+
Cell[4237, 138, 181, 4, 42, "Output",ExpressionUUID->"991bafb7-d02c-4068-92a4-6351b0906bde"]
316+
}, Open ]]
317+
}, Open ]],
318+
Cell[CellGroupData[{
319+
Cell[4467, 148, 129, 0, 56, "Subsubsection",ExpressionUUID->"16f79d81-0a75-40a5-92a6-f1ae81c617c5"],
320+
Cell[CellGroupData[{
321+
Cell[4621, 152, 529, 15, 37, "Input",ExpressionUUID->"aa9787a5-a9e8-4c91-a0ce-4b41515f8ae5"],
322+
Cell[5153, 169, 164, 3, 42, "Output",ExpressionUUID->"303ce45e-606b-4890-ba26-399cd5ac40eb"]
323+
}, Open ]],
324+
Cell[CellGroupData[{
325+
Cell[5354, 177, 551, 15, 37, "Input",ExpressionUUID->"31477670-68ba-454d-9a10-4a4e3aeb9039"],
326+
Cell[5908, 194, 254, 7, 42, "Output",ExpressionUUID->"3c5466cf-df1a-4061-9402-a1236477d8a7"]
327+
}, Open ]]
328+
}, Open ]],
329+
Cell[CellGroupData[{
330+
Cell[6211, 207, 129, 0, 56, "Subsubsection",ExpressionUUID->"f501fbf3-dd43-45f5-91da-f4625d4977db"],
331+
Cell[CellGroupData[{
332+
Cell[6365, 211, 525, 15, 37, "Input",ExpressionUUID->"1b33b278-c8a2-4f16-804e-8b749cfa1adb"],
333+
Cell[6893, 228, 166, 3, 42, "Output",ExpressionUUID->"1a697d21-afc4-4fdc-84dd-755797fc03e8"]
334+
}, Open ]],
335+
Cell[CellGroupData[{
336+
Cell[7096, 236, 552, 15, 37, "Input",ExpressionUUID->"f702b32f-fca8-42f2-bbc9-515beea2b3df"],
337+
Cell[7651, 253, 255, 7, 42, "Output",ExpressionUUID->"6173f5fb-9a3a-463b-934d-e78ba3b4e5e0"]
338+
}, Open ]]
339+
}, Open ]]
340+
}
341+
]
342+
*)
343+
Binary file not shown.

0 commit comments

Comments
 (0)