Permalink
Browse files

BUG: ticket:1530 cauchy fit, cheap fix for starting values

  • Loading branch information...
1 parent 0536b9f commit 3a209d1e74c54b5344942d8c4010142bbf02d25a @josef-pkt josef-pkt committed with rgommers Oct 31, 2011
Showing with 10 additions and 0 deletions.
  1. +2 −0 scipy/stats/distributions.py
  2. +8 −0 scipy/stats/tests/test_distributions.py
@@ -2464,6 +2464,8 @@ def _stats(self):
return inf, inf, nan, nan
def _entropy(self):
return log(4*pi)
+ def _fitstart(data, args=None):
+ return (0, 1)
cauchy = cauchy_gen(name='cauchy')
@@ -757,6 +757,14 @@ def test_frozen_fit_ticket_1536():
expected = np.array([floc, np.sqrt(((x-floc)**2).mean())])
assert_almost_equal(params, expected, decimal=4)
+def test_regression_ticket_1530():
+ """Check the starting value works for Cauchy distribution fit."""
+ np.random.seed(654321)
+ rvs = stats.cauchy.rvs(size=100)
+ params = stats.cauchy.fit(rvs)
+ expected = (0.045, 1.142)
+ assert_almost_equal(params, expected, decimal=1)
+
if __name__ == "__main__":
run_module_suite()

0 comments on commit 3a209d1

Please sign in to comment.