Time series analysis: seasonal differencing - time-series

I'm using nsdiffs() to test if seasonal differencing is required.
This is my time series:
(28.35 ,
51.89 ,
37.26 ,
48.22 ,
30.93 ,
43.54 ,
35.30 ,
59.45 ,
49.41 ,
65.61 ,
36.59 ,
51.25 ,
31.42 ,
53.16 ,
39.41 ,
64.45 ,
43.94 ,
79.36 ,
52.93 ,
74.99 ,
55.03 ,
86.93 ,
41.69 ,
62.77 ,
41.29 ,
59.95 ,
40.07 ,
66.13 ,
47.15 ,
85.12 ,
74.44 ,
76.42 ,
49.17 ,
82.66 ,
49.88 ,
70.98 ,
52.83 ,
75.85 ,
61.40 ,
85.20 ,
61.99 ,
90.68 ,
48.05 ,
74.20 ,
41.70 ,
68.00 ,
46.41 ,
82.23 ,
62.18 ,
88.65 ,
65.21 ,
100.90 ,
46.63 ,
83.53 ,
56.57 ,
108.87 ,
51.01 ,
80.15 ,
57.03 ,
87.91 ,
62.41 ,
96.11 ,
71.41 ,
82.08 ,
62.50 ,
88.52 ,
60.53 ,
100.15 ,
67.74 ,
111.88 ,
74.64 ,
138.64 ,
97.88 ,
153.88 ,
111.34 ,
176.40 ,
67.57 ,
111.95 ,
72.36 ,
118.85 ,
82.19 ,
136.88 ,
84.95 ,
160.58 ,
64.13 ,
111.32 ,
64.65 ,
113.82 ,
74.75 ,
118.76 ,
86.28 ,
166.36 ,
71.82 ,
119.83 ,
67.64 ,
116.17 ,
77.83 ,
130.64 ,
95.23 ,
149.84 ,
115.97 ,
189.69 ,
96.35 ,
137.51 ,
82.04 ,
139.19 ,
70.68 ,
135.22 ,
69.84 ,
105.70 ,
65.47 ,
111.47 ,
63.71 ,
108.23 ,
66.81 ,
117.96 ,
86.82 ,
141.74 ,
71.97 ,
122.65 ,
89.35 ,
133.97 ,
110.07 ,
159.18 ,
117.40 ,
196.90 ,
167.69 ,
244.75 ,
85.43 ,
135.54 ,
70.51 ,
118.30 ,
78.83 ,
139.85 ,
108.57 ,
162.66 ,
139.03 ,
203.72 ,
94.37 ,
135.92 ,
80.35 ,
128.63 ,
90.20 ,
157.56 ,
112.91 ,
177.07 ,
147.28 ,
221.67 ,
90.86 ,
142.66 ,
93.96 ,
157.89 ,
121.50 ,
200.35 ,
140.08 ,
306.36 ,
187.86 ,
171.39 ,
113.52 ,
174.20 ,
108.89 ,
170.53 ,
121.49 ,
193.65 ,
148.72 ,
210.61 ,
168.46 ,
250.40 ,
213.54 ,
181.78 ,
126.56 ,
190.46 ,
137.85 ,
226.25 ,
148.68 ,
235.04 ,
170.39 ,
275.04 ,
106.68 ,
163.24 ,
109.15 ,
186.46 ,
129.33 ,
156.18 ,
91.03 ,
159.87 ,
119.43 ,
164.51 ,
92.84 ,
145.00 ,
87.02 ,
156.55 ,
92.76 ,
140.93 ,
102.72 ,
143.41 ,
92.11 ,
159.72 ,
96.44 ,
156.98 ,
151.38 ,
221.12 ,
174.89 ,
242.53 ,
117.66 ,
163.44 ,
111.25 ,
169.58 ,
103.27 ,
163.09 ,
105.62 ,
186.64 ,
124.75 ,
145.65 ,
108.31 ,
165.30 ,
101.91 ,
156.55 ,
101.72 ,
147.11 ,
106.25 ,
185.68 ,
146.83 ,
192.05 ,
101.46 ,
153.65 ,
105.91 ,
170.10 ,
97.07 ,
165.05 ,
106.06 ,
167.25 ,
102.68 ,
197.21 ,
99.19 ,
169.58 ,
106.66 ,
196.44 ,
103.46 ,
165.62 ,
108.77 ,
188.32 ,
117.03 ,
241.48 ,
171.60 ,
189.78 ,
110.79 ,
166.22 ,
116.14 ,
229.75 ,
144.17 ,
205.75 ,
137.51 ,
216.51 ,
111.98 ,
186.34 ,
138.92 ,
218.35 ,
172.29 ,
271.53 ,
143.24 ,
272.35 ,
274.90 ,
232.97 ,
238.00 ,
234.88 ,
172.19 ,
260.82 ,
143.12 ,
217.38 ,
136.56 ,
209.91 ,
144.57 ,
253.58 ,
171.79 ,
264.78 ,
189.01 ,
298.97 ,
231.23 ,
315.29 ,
198.05 ,
318.52 ,
183.21 ,
232.33 ,
161.40 ,
261.82 ,
145.56 ,
218.09 ,
140.13 ,
215.00 ,
154.87 ,
293.88 ,
164.71 ,
256.85 ,
192.69 ,
306.87 ,
255.16 ,
382.27 ,
298.13 ,
438.22 ,
183.88 ,
279.56 ,
217.82 ,
371.55 ,
269.81 ,
383.89 ,
211.72 ,
330.02 ,
217.97 ,
312.64 ,
227.47 ,
329.25 ,
238.65 ,
363.80 ,
280.39 ,
453.38 ,
363.84 ,
486.65 ,
647.67 ,
534.41 ,
219.69 ,
292.16 ,
209.73 ,
336.33 ,
226.43 ,
336.23 ,
249.48 ,
359.84 ,
188.05 ,
307.73 ,
231.67 ,
330.43 ,
252.22 ,
379.30 ,
293.54 ,
413.67 ,
384.64 ,
515.86 ,
482.36 ,
438.12)
Lets call this time series sales.
When I try to do that:
ns <- nsdiffs(ts(sales))
I got the following error:
Error in nsdiffs(sales) : Non seasonal data
Could anybody please explain to me why?
Thanks!

The problem perhaps was that the argument supplied to the function nsdiffs did not have an attribute frequency extractable using the function frequency. If you supply a simple vector to the function nsdiffs, the function will try extracting the frequency, fail and emit the error message "Non seasonal data". You need to supply a time series object that has the attribute frequency, such as a ts object (and you have to specify the frequency when creating a ts object, which you failed to do), then it should work. This can be seen by looking at the code of the function nsdiffs: simply type nsdiffs in R and press "Enter". However, the need to supply an object with a frequency attribute is not documented in sufficient detail in the help file, which may be a little confusing.

Related

TensorFlow in iOS Swift:Binary classification problem

I am having some issues while getting output in TensorFlow Model(tflite).
This is my input:
let inputInfo:[Float32] : [-1.0291401 , 1.6121695 , 0.58366895, -0.25974554, 2.6633718 ,
0.39398468, 1.2648116 , -1.0617405 , 1.0997621 , -0.01813432,
-0.02543107, 1.9113901 , 0.30188444, 0.3199759 , 0.07759953,
0.23082322, 2.0959156 , -0.42658705, 0.08775132, 3.4258583 ,
-1.0573974 , 0.7249298 , -1.1119401 , -0.72663903, -0.74873704,
-0.387724 , -0.14288527, -0.39554232, -0.10774904, -0.0911286 ,
0.40389383, -0.169619 , -1.1736624 ]
let inputData = Data(bytes: &inputInfo, count: inputInfo.count * MemoryLayout<Float32>.stride)
print(inputData)
try interpreter?.copy(inputData, toInputAt: 0)
After passing this array of Float32 type as input I am getting below result in output:
Output:
TensorFlowLite.Tensor(name: "Identity", dataType: TensorFlowLite.Tensor.DataType.float32, shape: TensorFlowLite.Tensor.Shape(rank: 2, dimensions: [1, 1]), data: 4 bytes, quantizationParameters: nil)
For getting the expexcted output result I am using this code:
let outputTensor = try self.interpreter?.output(at: 0)
let finalOutput = [Float32](unsafeData: outputTensor!.data)
print(finalOutput)
4.6533377e+33
Here expected output should be some numbers between 0 & 1(like 0.8,0.9) but my final output is beyond that expected output.
I am stuck here,please help.

How can I get the coordinates of some point on an already-settled Graph?

In manim, I want to get the coordinates of a certain point on a graph?
class Formula2(GraphScene):
CONFIG = {
"x_min" : 0,
"x_max" : 100.3,
"x_tick_frequency": 10,
"y_min" : 0,
"y_max" : 100.3,
"y_tick_frequency": 10,
"graph_origin" : [-4,-3,0] ,
"function_color" : RED ,
"axes_color" : WHITE ,
"x_labeled_nums" : range(10,100,10),
"y_labeled_nums" : range(10,100,10)
}
def construct(self):
self.setup_axes(animate=True)```
What's my next method or function?
You can use the method coords_to_point, more details in my video

how to load a vector of certrain word form word2vec saved model?

how can i find a respective words vector from previous trained word2vec model?
data = {'one': array([-0.06590105, 0.01573388, 0.00682817, 0.53970253, -0.20303348,
-0.24792041, 0.08682659, -0.45504045, 0.89248925, 0.0655603 ,
......
-0.8175681 , 0.27659689, 0.22305458, 0.39095637, 0.43375066,
0.36215973, 0.4040089 , -0.72396156, 0.3385369 , -0.600869 ],
dtype=float32),
'two': array([ 0.04694849, 0.13303463, -0.12208422, 0.02010536, 0.05969441,
-0.04734801, -0.08465996, 0.10344813, 0.03990637, 0.07126121,
......
0.31673026, 0.22282903, -0.18084198, -0.07555179, 0.22873943,
-0.72985399, -0.05103955, -0.10911274, -0.27275378, 0.01439812],
dtype=float32),
'three': array([-0.21048863, 0.4945509 , -0.15050395, -0.29089224, -0.29454648,
0.3420335 , -0.3419629 , 0.87303966, 0.21656844, -0.07530259,
......
-0.80034876, 0.02006451, 0.5299498 , -0.6286509 , -0.6182588 ,
-1.0569025 , 0.4557548 , 0.4697938 , 0.8928275 , -0.7877308 ],
dtype=float32),
'four': ......
}
now i want to obtain like
word = "one"
wordvector = data.get_vector(word)
and returns
[-0.06590105, 0.01573388, 0.00682817, 0.53970253, -0.20303348,
-0.24792041, 0.08682659, -0.45504045, 0.89248925, 0.0655603 ,
......
-0.8175681 , 0.27659689, 0.22305458, 0.39095637, 0.43375066,
0.36215973, 0.4040089 , -0.72396156, 0.3385369 , -0.600869 ]
one_array = data['one']
datais a dictionary. To get the value of a dictionary for a certain key, you call value = dict[key].
With one_list = data['one'].tolist(), you get the wordvector of the word 'one' as a list, which seems to be your expected output.

Remove duplicity from array of array iOS SDK

I have array of array and want to eliminate duplicity. How can I do this
<__NSArrayM 0x9175640>(
<__NSArrayI 0x919ec80>(
http://scontent-b.cdninstagram.com/hphotos-xfp1/outbound-distilleryimage2/t0.0-17/OBPTH/dccd6b4cb15211e3aeb912af24c9b212_5.jpg,
47738394,
evdokia_bach,
Evdokia Bach,
https://instagramimages-a.akamaihd.net/profiles/profile_47738394_75sq_1388023560.jpg
)
,
<__NSArrayI 0x919eca0>(
http://scontent-b.cdninstagram.com/hphotos-xpf1/outbound-distilleryimage10/t0.0-17/OBPTH/e27402bab15011e39584123223ad70da_5.jpg,
47799994,
allen,
allen warden,
https://instagramimages-a.akamaihd.net/profiles/profile_47738394_75sq_1388023560.jpg
)
,
<__NSArrayI 0x919ecc0>(
http://scontent-a.cdninstagram.com/hphotos-xaf1/outbound-distilleryimage6/t0.0-17/OBPTH/5794c4e0b15011e397e2122466b7dba2_5.jpg,
47738394,
evdokia_bach,
Evdokia Bach,
https://instagramimages-a.akamaihd.net/profiles/profile_47738394_75sq_1388023560.jpg
)
,
<__NSArrayI 0x919ece0>(
http://scontent-b.cdninstagram.com/hphotos-xpf1/outbound-distilleryimage11/t0.0-17/OBPTH/0f0916eab15011e3942d12c36745260f_5.jpg,
47738394,
evdokia_bach,
Evdokia Bach,
https://instagramimages-a.akamaihd.net/profiles/profile_47738394_75sq_1388023560.jpg
)
)
)
I want only unique array how can i do this ?

Virtual Memory Handling

I'm working on a PE Loader, just like windows loader
my target is an executable not DLL,i tried first loadlibrary but faced reallocation problems,got some code to fix it, but it didn't work with all targets (some exe's needs to be loaded at the same BaseAdress to work probably
so i got to the point, i've to implement my loader to ensure the BaseAddress issue and no need for reallocation
I'm forcing my application to load at a high addr(0x10000000),while using VirtualAlloc to allocate memory for headers & sections for the target app
i use VirtualQuery to see the state of the address i want to allocate, if not free i use UnMapViewOfFile if Page type MEM_MAPPED else VirtualFree(MEM_RELEASE)
The problem is that if the memory pages are MEM_MAPPED & MEM_COMMIT (always page file backed pages) all methods fails with error code 0x57 ERROR_INVALID_PARAMETER
looking for solutions/ideas here's the code :
MylpAddr = (DWORD)lpAddr ;
MemInfo.RegionSize = 0 ;
NtUnmapViewOfSection= (NTUNMAPVIEWOFSECTION)GetProcAddress(LoadLibrary(TEXT("ntdll.dll")), "NtUnmapViewOfSection");
NtProtectVirtualMemory= (NTPROTECTVIRTUALMEMORY)GetProcAddress(LoadLibrary(TEXT("ntdll.dll")), "NtProtectVirtualMemory");
NtUnlockVirtualMemory= (NTUNLOCKVIRTUALMEMORY)GetProcAddress(LoadLibrary(TEXT("ntdll.dll")), "NtUnlockVirtualMemory");
GetSystemInfo(&siSysInfo);
szPage = siSysInfo.dwPageSize ;
i = VirtualQuery( (LPCVOID)MylpAddr , &MemInfo , 0x20 ) ;
if (!i) return NULL ;
if ( !(MemInfo.State & MEM_FREE) )
{
if ( MemInfo.Type & MEM_MAPPED )
{
hProc = GetCurrentProcess() ;
szPage = MemInfo.RegionSize ;
i = NtUnlockVirtualMemory(hProc , (PVOID *)MemInfo.AllocationBase , (PULONG)szPage , LOCK_VM_IN_WORKING_SET | LOCK_VM_IN_RAM );
i = NtProtectVirtualMemory(hProc , (PVOID *)MemInfo.AllocationBase , (PULONG)szPage , PAGE_READWRITE , &OldProt ) ;
i = NtUnmapViewOfSection( hProc , (LPVOID)MemInfo.AllocationBase );
i = UnmapViewOfFile( (LPVOID)MemInfo.AllocationBase );
if (!i) i =1 ;
}
else
{
j = VirtualUnlock(MemInfo.BaseAddress , MemInfo.RegionSize);
i = VirtualFree( (LPVOID)MemInfo.AllocationBase , NULL , MEM_RELEASE ) ;
}
if (!i) return NULL ;
}
MylpAddr = (DWORD)VirtualAlloc( lpAddr , dwSize , AllocType , ProtFlags );
Sorry for bringing up such an old question, I just thought it might help someone.
As far as I know, to fork a process you must have used CreateProcess function. Therefore you need to use VirtualQueryEx and VirtualAllocEx instead of VirtualQuery and VirtualAlloc. Also replace hProc value with a handle to your created process. I also noticed that you have explicitly used 0x20 as dwLength that you probably need to change it with dwSize.In summary:
PROCESS_INFORMATION piProcessInformation;
ZeroMemory(&piProcessInformation,sizeof(PROCESS_INFORMATION));
if(CreateProcess(NULL,processName,NULL,NULL,false,CREATE_SUSPENDED,NULL,NULL,&suStartUpInformation,&piProcessInformation))
{
cContext.ContextFlags = CONTEXT_FULL;
GetThreadContext(piProcessInformation.hThread,&cContext);
i = VirtualQueryEx(piProcessInformation.hProcess, (LPCVOID)MylpAddr , &MemInfo , dwSize ) ;
if (!i) return NULL ;
if ( !(MemInfo.State & MEM_FREE) )
{
if ( MemInfo.Type & MEM_MAPPED )
{
// hProc = GetCurrentProcess() ; No need to this line
szPage = MemInfo.RegionSize ;
i = NtUnlockVirtualMemory(piProcessInformation.hProcess , (PVOID *)MemInfo.AllocationBase , (PULONG)szPage , LOCK_VM_IN_WORKING_SET | LOCK_VM_IN_RAM );
i = NtProtectVirtualMemory(piProcessInformation.hProcess , (PVOID *)MemInfo.AllocationBase , (PULONG)szPage , PAGE_READWRITE , &OldProt ) ;
i = NtUnmapViewOfSection( piProcessInformation.hProcess , (LPVOID)MemInfo.AllocationBase );
i = UnmapViewOfFile( (LPVOID)MemInfo.AllocationBase );
if (!i) i =1 ;
}
else
{
j = VirtualUnlock(MemInfo.BaseAddress , MemInfo.RegionSize);
i = VirtualFreeEx(piProcessInformation.hProcess, (LPVOID)MemInfo.AllocationBase , NULL , MEM_RELEASE ) ;
}
if (!i) return NULL ;
}
MylpAddr = (DWORD)VirtualAllocEx(piProcessInformation.hProcess, lpAddr , dwSize , AllocType , ProtFlags );
}

Resources