You can attribute to God any phenomenon that you don't have any other explanation for, but that isn't a useful practice. First of all, if something happens at God's whim, there is no way we can predict it or relate the resulting phenomenon to any other phenomenon, because we have no special insight into God's whims. We can make the a priori assumption that God allows His whims to come into play as a result of some act of behavior that we don't normally do, e.g., one of those behaviors that we call a "sin"; but unless there is some observable correlation between the "sin" and the subsequent behavior (e.g., the destruction of Nineveh) there is no point to the assumption.
In my experience there is a lot of behavior that I don't do that happens without any divine retribution. So unless there is some correlation between acts of human behavior and results that require the explanation of God's whim, we might just as well leave God's whim out of it. And with regard to "sins", unless there are actions that are universally followed by a retributory phenomenon not attributable to some natural cause (like falling after stepping off the edge of a cliff), the concept of "sin" is not a useful one. What we should do is look for a natural explanation and leave God out of it unless we can't find something natural.
An "act of God" should be regarded as a memorandum of a missing explanation, and nothing more than that.
There is a situation in which the idea of God, or beings whose nature is between God and man, is useful in a gedankenexperiment. Einstein, in figuring out the consequences of phenomena explained by his "Theory of Special Relativity" used the metaphor of a railroad car traveling at almost the speed of light. We have no experience of a real railroad car traveling at that speed, nor the experience of any tangible vehicle traveling at anywhere near that speed, nor the experiences of the sensations of a human passenger in such a situation. Yet the results of Einstein's thinking were physical phenomena that were observable.
This technique of thinking about a situation "as if" you were able to be there and observe it, which physicists call a gedankenexperiment because the significant theoretical scientists of the nineteenth century were german, is useful in physics because the phenomena that we observe in physics do not depend on the human characteristics of the observer. They were not used in other sciences where the human characteristics would have an influence on the observations. Because of that we got sloppy in the way we used the procedure, and Einstein himself got caught by the sloppyness.
Einstein was quoted as saying various things like "God may be a rascal but he is not a gambler". But that was merely based on the quoter's assumption that God has the same limited ability to observe that we have. What he said in a more thoughtful style was: "Quantum mechanics is certainly imposing. But an inner voice tells me that it is not yet the real thing. The theory says a lot, but does not really bring us any closer to the secret of the "old one." I, at any rate, am convinced that He does not throw dice."
But a simplistic view of causality that does not include the notion of probability doesn't work. So the question that should be asked is: "How do you describe, in terms consistent with modern science, a time-sequence of phenomena that is consistent with both the deterministic view of the past that is a characteristic of human observations and the omniscience of entities that can observe like God does. We label those entities Deus ex Machina or DeM and we don't specify any other characteristic besides the ability to be omniscient because we don't want to limit the characteristics of God unnecessarily.
In May Day 2011 we discuss in some detail the limitations on the observation of human behavior, including the provision that humans have "free will". We stipulate that in any one observation a human observer (or group of observers who are to come to a consensus on their observation) will observe one, and only one, response resulting from a given stimulus. That's the inherent limitation of human observation.
We can also stipulate that a DeM can observe all the possible responses that constitute the repertoire of a behaver by existing in the same multi-dimensional mathematical space in which the characteristics of the behaver are represented by a matrix. In other words, in order to have omniscience, and be able to observe simultaneously all the possible responses that the behaver might make, the DeM has to exist in a different kind of space than we do. That isn't a problem any more, because multi-dimensional spaces are part of the repertoire of concepts that philosophers have available, and there is no reason that theologians can't use them as well.
But consider if a particular DeM is assigned to a particular behaver (like a guardian angel might be). Then, while that DeM might be able to observe, from a point outside time, all the things that have happened, will happen, might happen and might have happened to that behaver; the DeM would be limited to happenings related to that individual behaver. But we can then consider a DeM of the next higher order that is aware of all the things that all the angels are aware of. That DeM would have the kind of omniscience that we attribute to God: the ability not just to observe any happening that any behaver in our universe might be able to observe, but the ability to have already observed any such even in the history of our universe.
There might be other universes, outside our ability to observe under any conditions, that God may observe, but they would be irrelevant to us.
That kind of God would be consistent with the strategy of knowledge acquisition we call "science", but it has implications that would make it inconsistent with a lot of theological propositions.
If God is aware of everything that has happened, might have happened, will happen, and might happen, to God the history of the Universe is a fixed object. We might only be capable of being aware of a part of the trajectory toward the past, but we have no right to saddle God with that limitation.
The consequence is that we have no right to ask God to change the history of the Universe for our benefit. The future we would like, as opposed to the future we anticipate as a result of our actions, if it is at all possible, is something that God is already aware of. God sees it as a future that resulted from a lifetime of events that that version of you participated in; events that were possible for the version of you that you are aware of, but that you chose not to participate in. The way that God could give you that future would be to also give you that past; and the fact that there is a "you" experiencing this life and another "you" experiencing one you think might be better is no different to God than the situation where the two "you"s, with their appropriate histories are interchanged. Your identity is in your history, not your future.
That does not mean that prayer to God is worthless. If your prayer has the result that you live a life more consistent with your hoped-for future, you will be more likely to experience that future. But prayer doesn't change the past, because God has already experienced that. It can change the future, but only if you act, in the future, in a way consistent with your prayers.
In general, don't expect anything special from God, just do the best you can.