<html>
<div id="jxgbox" class="jxgbox" style="height:400px; width:600px;"></div>
</html>

<script>
   var board = CreateBassModelBoard();

   var p_slider = board.create('slider', [[0,-2],[10,-2], [0.0,0.03, 1.0]], {name:'p',size:2}, {withLabel:false});
   var q_slider = board.create('slider', [[0,-5],[10,-5], [0.0,0.32, 1.0]], {name:'q',size:1}, {withLabel:false});
   var M_slider = board.create('slider', [[0,0],[0,200], [0.0,100, 2000]], {name:'Market potential,size:1'}, {withLabel:false});

   CreateBass_cF_fsumGraph(board, M_slider);
   CreateBass_fGraph(board, M_slider);

   function CreateBassModelBoard()
   {
      var board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-4,  12, 5, -7], keepaspectratio:true, axis:true, showNavigation:true});
      JXG.removeEvent(board.containerObj, 'mousewheel', board.mouseWheelListener, board);
      JXG.removeEvent(board.containerObj, 'DOMMouseScroll', board.mouseWheelListener, board); 

      return board;
   }

   function Bass_cF_fsum(M, p, q, t)
   {
      Value = M * (1 - exp_p_plus_q_times_t (p,q,t)) / (1+((q/p) * exp_p_plus_q_times_t (p,q,t)));
      return Value ;
   }

   function exp_p_plus_q_times_t (p,q,t)
   {
      return Math.exp (-t * (p + q));
   }

   function Bass_f( M, p, q, t)
   {
      Value = M *  ((Math.pow(p+q,2)/p) * exp_p_plus_q_times_t (p,q,t) / Math.pow(1+(q/p) * exp_p_plus_q_times_t (p,q,t),2))
      return Value ;
   }

   function CreateBass_fGraph(board, M_slider)
   {
      var bassfunction = board.create
      (
            'functiongraph', 
            [
               function(x)
               {
                  return Bass_f( M_slider.Y(), p_slider.Value(), q_slider.Value(), x);
               },
               0,
               20
            ]
      );
   } 

   function CreateBass_cF_fsumGraph(board, M_slider)
   {
      var bassfunction = board.create
      (
            'functiongraph', 
            [
               function(x)
               {
                  return Bass_cF_fsum( M_slider.Y(), p_slider.Value(), q_slider.Value(), x);
               },
               0,
               20
            ]
            ,{'strokeColor':'red'}
      );
   } 
</script>
bag
marketing_public
created
Sat, 10 Mar 2012 14:41:14 GMT
creator
dirkjan
modified
Sat, 10 Mar 2012 14:41:14 GMT
modifier
dirkjan
tags
Model
creator
dirkjan