# Fog vs. Cloud Computing: Should I Stay or Should I Go? +
## Modeling Platforms
### Estimating \(f\)  
We can find \(s\) and \(t\) by measuring the hardware and software infrastructures according to the type of cost for which we are looking. However, \(f\) also depends on the data, so it cannot be as easily calculated unless we know all data points in advance. What we can do instead is estimate \(f\) by looking at a subset of the values. We can start by plotting a graph to guide our analysis of the relationship between \(C_{f}\) and \(C_{c}\). In this graph, the horizontal axis represents the fog computing cost as a function of the number of stream values being processed in the fog. Therefore, a case where all \(z\) data points are processed in the fog would be represented by a point crossing this axis. The value of this point, which we call \(C_{f0}\), can be calculated by Equation (1). In the same way, the vertical axis represents the cloud computing cost from the point of view of the device as a function of the number of stream values being processed in the cloud, and a case where all values are handled by the cloud is represented by a point crossing this axis. The value of this point, which we call \(C_{c0}\), can be found with the help of Equation (2). We can also add more points to the graph by considering the cases where part of the data is processed by the fog, while the rest is processed by the cloud. For each additional sensor reading that we process in the fog instead of just sending to the cloud, we add \(r+t+s\cdot f+i\) to the value in the horizontal axis and subtract \(r+s+i\) from the value in the vertical axis. It is possible to repeat this process until all possibilities are represented in the graph. Lastly, we draw a line that passes through these points, which will give us the linear equation represented in Equation (4). \[C_{c}-C_{c0}=-\frac{C_{c0}}{C_{f0}}\cdot C_{f} \tag{4}\]Figure 1 shows an example of a graph constructed with the method described in this section. In this graph, \(z=10\) and all the lines have the same values for all variables, except \(f\). Considering that we are estimating \(f\) on the device itself while it is collecting and processing the data, we do not need to worry about situations where \(C_{f}\leq C_{c}\), as the values are processed on the device before we make our decision and nothing will change if fog computing is considered to be more profitable. To evaluate the scenario where \(C_{f}>C_{c}\), we can think about the worst-case scenario of \(f=1\) (i.e., all data are passing the filter) and determine the size of the penalty that we are willing to pay to be able to make a more informed decision about the value of \(f\). First, we calculate the penalty (\(p\)) of processing each additional value on the fog when it would be more profitable to do so on the cloud using Equation (5). This value is a percentage of increase in cost. \[p=\frac{\frac{C_{f0}}{C_{c0}}-1}{z} \tag{5}\]  
As \(C_{f}>C_{c}\), \(C_{f0}/C_{c0}>1\), and thus, \(p\) is always positive. Then, we can establish a threshold for the maximum penalty that we are willing to pay. For example, if \(p=0.0175\), each additional point processed in the fog will increase the computational cost by \(1.75\%\). Therefore, if we are willing to risk up to a \(10\%\) increase in cost, we can test if the first \(v=\lfloor 10/1.75\rceil=5\) data points pass the filter or not. In this case, if \(n=3\) out of the five values pass the filter, we can estimate that \(f=n/v=3/5=0.6\) and then plug this value into Equation (3) to make our decision. It is up to the user to define what is a reasonable trade-off given the parameters of their specific scenario. Table A1 in Appendix A has a summary of the notation introduced in this subsection. Examining Equation (4) and Figure 1 also gives us additional insights when we evaluate the slope of the line, which is \(-C_{c0}/C_{f0}\). When \(C_{f}=C_{c}\), the slope is \(-1\) (as is the case of the gray line with circular markers).