Here are the examples of the python api numpy.std taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
145 Examples
3
View Complete Implementation : scaled_updates.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : SBU-BMI
Copyright BSD 3-Clause "New" or "Revised" License
Author : SBU-BMI
def _new_update_deltas(self, network, parameter_vws, grads):
learning_rate = network.find_hyperparameter(["sgd_learning_rate",
"learning_rate"],
0.1)
# HACK changes the rest of this node... mostly restructuring
deltas = {}
for vw, grad in zip(parameter_vws, grads):
initial_std = np.std(vw.value)
# prevent multiplying by 0 std
if initial_std == 0:
initial_std = 1.0
factor = treeano.utils.as_fX(-learning_rate * initial_std ** 2)
deltas[vw.variable] = factor * grad
return treeano.UpdateDeltas(deltas)
3
View Complete Implementation : scaled_updates.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : SBU-BMI
Copyright BSD 3-Clause "New" or "Revised" License
Author : SBU-BMI
def _new_update_deltas(self, network, parameter_vws, grads):
learning_rate = network.find_hyperparameter(["sgd_learning_rate",
"learning_rate"],
0.1)
# HACK changes the rest of this node... mostly restructuring
deltas = {}
for vw, grad in zip(parameter_vws, grads):
initial_std = np.std(vw.value)
# prevent multiplying by 0 std
if initial_std == 0:
initial_std = 1.0
factor = treeano.utils.as_fX(-learning_rate * initial_std ** 2)
deltas[vw.variable] = factor * grad
return treeano.UpdateDeltas(deltas)
3
View Complete Implementation : scaled_updates.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : SBU-BMI
Copyright BSD 3-Clause "New" or "Revised" License
Author : SBU-BMI
def _new_update_deltas(self, network, parameter_vws, grads):
learning_rate = network.find_hyperparameter(["sgd_learning_rate",
"learning_rate"],
0.1)
# HACK changes the rest of this node... mostly restructuring
deltas = {}
for vw, grad in zip(parameter_vws, grads):
initial_std = np.std(vw.value)
# prevent multiplying by 0 std
if initial_std == 0:
initial_std = 1.0
factor = treeano.utils.as_fX(-learning_rate * initial_std ** 2)
deltas[vw.variable] = factor * grad
return treeano.UpdateDeltas(deltas)
3
View Complete Implementation : scaled_updates.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : SBU-BMI
Copyright BSD 3-Clause "New" or "Revised" License
Author : SBU-BMI
def _new_update_deltas(self, network, parameter_vws, grads):
learning_rate = network.find_hyperparameter(["sgd_learning_rate",
"learning_rate"],
0.1)
# HACK changes the rest of this node... mostly restructuring
deltas = {}
for vw, grad in zip(parameter_vws, grads):
initial_std = np.std(vw.value)
# prevent multiplying by 0 std
if initial_std == 0:
initial_std = 1.0
factor = treeano.utils.as_fX(-learning_rate * initial_std ** 2)
deltas[vw.variable] = factor * grad
return treeano.UpdateDeltas(deltas)
3
View Complete Implementation : test_binned_statistic.py
Copyright MIT License
Author : ktraunmueller
Copyright MIT License
Author : ktraunmueller
def test_2d_std(self):
x = self.x
y = self.y
v = self.v
stat1, binx1, biny1, bc = binned_statistic_2d(x, y, v, 'std', bins=5)
stat2, binx2, biny2, bc = binned_statistic_2d(x, y, v, np.std, bins=5)
astert_array_almost_equal(stat1, stat2)
astert_array_almost_equal(binx1, binx2)
astert_array_almost_equal(biny1, biny2)
3
View Complete Implementation : test_binned_statistic.py
Copyright MIT License
Author : ktraunmueller
Copyright MIT License
Author : ktraunmueller
def test_2d_std(self):
x = self.x
y = self.y
v = self.v
stat1, binx1, biny1, bc = binned_statistic_2d(x, y, v, 'std', bins=5)
stat2, binx2, biny2, bc = binned_statistic_2d(x, y, v, np.std, bins=5)
astert_array_almost_equal(stat1, stat2)
astert_array_almost_equal(binx1, binx2)
astert_array_almost_equal(biny1, biny2)
3
View Complete Implementation : histograms.py
Copyright MIT License
Author : PacktPublishing
Copyright MIT License
Author : PacktPublishing
def _hist_bin_scott(x):
"""
Scott histogram bin estimator.
The binwidth is proportional to the standard deviation of the data
and inversely proportional to the cube root of data size
(asymptotically optimal).
Parameters
----------
x : array_like
Input data that is to be histogrammed, trimmed to range. May not
be empty.
Returns
-------
h : An estimate of the optimal bin width for the given data.
"""
return (24.0 * np.pi**0.5 / x.size)**(1.0 / 3.0) * np.std(x)
3
View Complete Implementation : histograms.py
Copyright MIT License
Author : PacktPublishing
Copyright MIT License
Author : PacktPublishing
def _hist_bin_scott(x):
"""
Scott histogram bin estimator.
The binwidth is proportional to the standard deviation of the data
and inversely proportional to the cube root of data size
(asymptotically optimal).
Parameters
----------
x : array_like
Input data that is to be histogrammed, trimmed to range. May not
be empty.
Returns
-------
h : An estimate of the optimal bin width for the given data.
"""
return (24.0 * np.pi**0.5 / x.size)**(1.0 / 3.0) * np.std(x)
3
View Complete Implementation : histograms.py
Copyright MIT License
Author : PacktPublishing
Copyright MIT License
Author : PacktPublishing
def _hist_bin_scott(x):
"""
Scott histogram bin estimator.
The binwidth is proportional to the standard deviation of the data
and inversely proportional to the cube root of data size
(asymptotically optimal).
Parameters
----------
x : array_like
Input data that is to be histogrammed, trimmed to range. May not
be empty.
Returns
-------
h : An estimate of the optimal bin width for the given data.
"""
return (24.0 * np.pi**0.5 / x.size)**(1.0 / 3.0) * np.std(x)
3
View Complete Implementation : histograms.py
Copyright MIT License
Author : PacktPublishing
Copyright MIT License
Author : PacktPublishing
def _hist_bin_scott(x):
"""
Scott histogram bin estimator.
The binwidth is proportional to the standard deviation of the data
and inversely proportional to the cube root of data size
(asymptotically optimal).
Parameters
----------
x : array_like
Input data that is to be histogrammed, trimmed to range. May not
be empty.
Returns
-------
h : An estimate of the optimal bin width for the given data.
"""
return (24.0 * np.pi**0.5 / x.size)**(1.0 / 3.0) * np.std(x)