python numpy std vs scala breeze stddev2019 Community Moderator ElectionScala: What is the generic way to calculate standard deviationCalling an external command in PythonWhat are metaclasses in Python?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?How to get the current time in PythonHow can I make a time delay in Python?How to make a flat list out of list of lists?Does Python have a string 'contains' substring method?

An Undercover Army

3.5% Interest Student Loan or use all of my savings on Tuition?

How to write a chaotic neutral protagonist and prevent my readers from thinking they are evil?

Issue with units for a rocket nozzle throat area problem

I've given my players a lot of magic items. Is it reasonable for me to give them harder encounters?

What exactly is the meaning of "fine wine"?

Limpar string com Regex

A vote on the Brexit backstop

Precision notation for voltmeters

Propulsion Systems

Sort array by month and year

Can the Witch Sight warlock invocation see through the Mirror Image spell?

Does the US political system, in principle, allow for a no-party system?

What is the oldest European royal house?

Is the differential, dp, exact or not?

How to distinguish easily different soldier of ww2?

After Brexit, will the EU recognize British passports that are valid for more than ten years?

Why isn't P and P/poly trivially the same?

Is "cogitate" used appropriately in "I cogitate that success relies on hard work"?

Is divide-by-zero a security vulnerability?

What should I do when a paper is published similar to my PhD thesis without citation?

What does *dead* mean in *What do you mean, dead?*?

What would be the most expensive material to an intergalactic society?

Are small insurances worth it?



python numpy std vs scala breeze stddev



2019 Community Moderator ElectionScala: What is the generic way to calculate standard deviationCalling an external command in PythonWhat are metaclasses in Python?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?How to get the current time in PythonHow can I make a time delay in Python?How to make a flat list out of list of lists?Does Python have a string 'contains' substring method?










1















I'm currently working on migrating some python code to scala. I'm using breeze lib as a substitution for numpy.



Everything looks fine, but I faced different behaviour in output of standard deviation implementations:



Python:



series = np.array([1,4,5])
np.mean(series) // 3.3333333333333335
np.std(series) // 1.699673171197595


Scala:



val vector = breeze.linalg.Vector[Double](Array(1.0, 4.0, 5.0))
val mean = breeze.stats.mean(vector) // 3.3333333333333335
val std = breeze.stats.stddev(vector) // 2.081665999466133


I know how to reproduce python's behaviour in plain scala. Sample code is presented here: Scala: What is the generic way to calculate standard deviation



But I'm looking for a way to get it with breeze. Any ideas?










share|improve this question




























    1















    I'm currently working on migrating some python code to scala. I'm using breeze lib as a substitution for numpy.



    Everything looks fine, but I faced different behaviour in output of standard deviation implementations:



    Python:



    series = np.array([1,4,5])
    np.mean(series) // 3.3333333333333335
    np.std(series) // 1.699673171197595


    Scala:



    val vector = breeze.linalg.Vector[Double](Array(1.0, 4.0, 5.0))
    val mean = breeze.stats.mean(vector) // 3.3333333333333335
    val std = breeze.stats.stddev(vector) // 2.081665999466133


    I know how to reproduce python's behaviour in plain scala. Sample code is presented here: Scala: What is the generic way to calculate standard deviation



    But I'm looking for a way to get it with breeze. Any ideas?










    share|improve this question


























      1












      1








      1








      I'm currently working on migrating some python code to scala. I'm using breeze lib as a substitution for numpy.



      Everything looks fine, but I faced different behaviour in output of standard deviation implementations:



      Python:



      series = np.array([1,4,5])
      np.mean(series) // 3.3333333333333335
      np.std(series) // 1.699673171197595


      Scala:



      val vector = breeze.linalg.Vector[Double](Array(1.0, 4.0, 5.0))
      val mean = breeze.stats.mean(vector) // 3.3333333333333335
      val std = breeze.stats.stddev(vector) // 2.081665999466133


      I know how to reproduce python's behaviour in plain scala. Sample code is presented here: Scala: What is the generic way to calculate standard deviation



      But I'm looking for a way to get it with breeze. Any ideas?










      share|improve this question
















      I'm currently working on migrating some python code to scala. I'm using breeze lib as a substitution for numpy.



      Everything looks fine, but I faced different behaviour in output of standard deviation implementations:



      Python:



      series = np.array([1,4,5])
      np.mean(series) // 3.3333333333333335
      np.std(series) // 1.699673171197595


      Scala:



      val vector = breeze.linalg.Vector[Double](Array(1.0, 4.0, 5.0))
      val mean = breeze.stats.mean(vector) // 3.3333333333333335
      val std = breeze.stats.stddev(vector) // 2.081665999466133


      I know how to reproduce python's behaviour in plain scala. Sample code is presented here: Scala: What is the generic way to calculate standard deviation



      But I'm looking for a way to get it with breeze. Any ideas?







      python scala scala-breeze






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Oct 17 '18 at 13:46









      martineau

      68.8k1091185




      68.8k1091185










      asked Oct 17 '18 at 13:24









      NormalNormal

      5461423




      5461423






















          2 Answers
          2






          active

          oldest

          votes


















          3














          This is related to the number of degrees of freedom. Indeed,



          >>> np.std(series, ddof=1)
          2.081665999466133


          Which is the sample std. With breeze, something you can do to get the population std is



          var n = 3
          val std = breeze.stats.stddev(vector)*Math.pow((n-1)/n, .5)
          # 1.6996731711975948





          share|improve this answer

























          • Thanks for explanation. I've found related issue in breeze GitHub page: github.com/scalanlp/breeze/issues/507

            – Normal
            Oct 17 '18 at 13:40











          • @Normal This may be something you know but see my update regarding how to deal with this issue.

            – keepAlive
            Oct 17 '18 at 14:01






          • 1





            works for me, thanks!

            – Normal
            Oct 17 '18 at 14:26


















          0














          If keepAlive's solution don't work, you should change "n" to Double



          var n : Double = 3
          val std = breeze.stats.stddev(vector)*Math.pow((n-1)/n, .5)
          # 1.6996731711975948





          share|improve this answer






















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52856011%2fpython-numpy-std-vs-scala-breeze-stddev%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            3














            This is related to the number of degrees of freedom. Indeed,



            >>> np.std(series, ddof=1)
            2.081665999466133


            Which is the sample std. With breeze, something you can do to get the population std is



            var n = 3
            val std = breeze.stats.stddev(vector)*Math.pow((n-1)/n, .5)
            # 1.6996731711975948





            share|improve this answer

























            • Thanks for explanation. I've found related issue in breeze GitHub page: github.com/scalanlp/breeze/issues/507

              – Normal
              Oct 17 '18 at 13:40











            • @Normal This may be something you know but see my update regarding how to deal with this issue.

              – keepAlive
              Oct 17 '18 at 14:01






            • 1





              works for me, thanks!

              – Normal
              Oct 17 '18 at 14:26















            3














            This is related to the number of degrees of freedom. Indeed,



            >>> np.std(series, ddof=1)
            2.081665999466133


            Which is the sample std. With breeze, something you can do to get the population std is



            var n = 3
            val std = breeze.stats.stddev(vector)*Math.pow((n-1)/n, .5)
            # 1.6996731711975948





            share|improve this answer

























            • Thanks for explanation. I've found related issue in breeze GitHub page: github.com/scalanlp/breeze/issues/507

              – Normal
              Oct 17 '18 at 13:40











            • @Normal This may be something you know but see my update regarding how to deal with this issue.

              – keepAlive
              Oct 17 '18 at 14:01






            • 1





              works for me, thanks!

              – Normal
              Oct 17 '18 at 14:26













            3












            3








            3







            This is related to the number of degrees of freedom. Indeed,



            >>> np.std(series, ddof=1)
            2.081665999466133


            Which is the sample std. With breeze, something you can do to get the population std is



            var n = 3
            val std = breeze.stats.stddev(vector)*Math.pow((n-1)/n, .5)
            # 1.6996731711975948





            share|improve this answer















            This is related to the number of degrees of freedom. Indeed,



            >>> np.std(series, ddof=1)
            2.081665999466133


            Which is the sample std. With breeze, something you can do to get the population std is



            var n = 3
            val std = breeze.stats.stddev(vector)*Math.pow((n-1)/n, .5)
            # 1.6996731711975948






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Oct 17 '18 at 13:45

























            answered Oct 17 '18 at 13:30









            keepAlivekeepAlive

            3,18541224




            3,18541224












            • Thanks for explanation. I've found related issue in breeze GitHub page: github.com/scalanlp/breeze/issues/507

              – Normal
              Oct 17 '18 at 13:40











            • @Normal This may be something you know but see my update regarding how to deal with this issue.

              – keepAlive
              Oct 17 '18 at 14:01






            • 1





              works for me, thanks!

              – Normal
              Oct 17 '18 at 14:26

















            • Thanks for explanation. I've found related issue in breeze GitHub page: github.com/scalanlp/breeze/issues/507

              – Normal
              Oct 17 '18 at 13:40











            • @Normal This may be something you know but see my update regarding how to deal with this issue.

              – keepAlive
              Oct 17 '18 at 14:01






            • 1





              works for me, thanks!

              – Normal
              Oct 17 '18 at 14:26
















            Thanks for explanation. I've found related issue in breeze GitHub page: github.com/scalanlp/breeze/issues/507

            – Normal
            Oct 17 '18 at 13:40





            Thanks for explanation. I've found related issue in breeze GitHub page: github.com/scalanlp/breeze/issues/507

            – Normal
            Oct 17 '18 at 13:40













            @Normal This may be something you know but see my update regarding how to deal with this issue.

            – keepAlive
            Oct 17 '18 at 14:01





            @Normal This may be something you know but see my update regarding how to deal with this issue.

            – keepAlive
            Oct 17 '18 at 14:01




            1




            1





            works for me, thanks!

            – Normal
            Oct 17 '18 at 14:26





            works for me, thanks!

            – Normal
            Oct 17 '18 at 14:26













            0














            If keepAlive's solution don't work, you should change "n" to Double



            var n : Double = 3
            val std = breeze.stats.stddev(vector)*Math.pow((n-1)/n, .5)
            # 1.6996731711975948





            share|improve this answer



























              0














              If keepAlive's solution don't work, you should change "n" to Double



              var n : Double = 3
              val std = breeze.stats.stddev(vector)*Math.pow((n-1)/n, .5)
              # 1.6996731711975948





              share|improve this answer

























                0












                0








                0







                If keepAlive's solution don't work, you should change "n" to Double



                var n : Double = 3
                val std = breeze.stats.stddev(vector)*Math.pow((n-1)/n, .5)
                # 1.6996731711975948





                share|improve this answer













                If keepAlive's solution don't work, you should change "n" to Double



                var n : Double = 3
                val std = breeze.stats.stddev(vector)*Math.pow((n-1)/n, .5)
                # 1.6996731711975948






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 2 days ago









                Pablo López GallegoPablo López Gallego

                1




                1



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52856011%2fpython-numpy-std-vs-scala-breeze-stddev%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

                    Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

                    Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved