In this paper, the bidding problem in electricity markets is formulated from the viewpoint of a generation company. With focus on Iran's electricity market structure, the objective is to design an optimal linear bid function considering pay-as-bid pricing mechanism. The market clearing price is considered as a stochastic variable. The bidding problem is formulated as a nonlinear optimization problem from the viewpoint of a price-taker generation company. Then a numerical study is performed to show the effect of stochastic characteristics of market price on the optimal values of bidding parameters. In order to have more expected profit, a mathematical problem is designed and solved to partition the generation capacity. The main aim of this paper is presentation of a classic method to find the optimal bid function while from the viewpoint of a price-taker generation company in a pay-as-bid electricity market. An example is designed to calculate a linear bid function using the proposed technique. Also a comparison between step-wise and linear bidding is presented.